Making sense of sequences of values in code

Suppose that you have encountered the following C++ code:

static const double P9[15][9] = { {0.0435820277, 0.167794347, 0.147040722, 0.125310654, 0.10147112, 0.10376347, 0.115973878, 0.107056197, 0.0880075845}, {0.0435817033, 0.167795985, 0.1470426, 0.125311016, 0.101470666, 0.103763084, 0.115972864, 0.107055437, 0.0880066471}, {0.0435798639, 0.167797087, 0.147042073, 0.125313291, 0.101470979, 0.103761847, 0.115973234, 0.107054351, 0.0880072753}, {0.043578895, 0.167797426, 0.147041988, 0.125313875, 0.101470922, 0.103761581, 0.115973137, 0.107054001, 0.0880081751}, {0.0435786725, 0.167797743, 0.1470428, 0.125313553, 0.101470946, 0.103761391, 0.115973188, 0.10705364, 0.0880080663}, {0.0435779307, 0.167797788, 0.147042734, 0.125314068, 0.101471449, 0.10376142, 0.115973187, 0.107053473, 0.0880079505}, {0.043576761, 0.167801375, 0.147042624, 0.125314075, 0.101470546, 0.103761069, 0.115973226, 0.107051966, 0.0880083593}, {0.0435771819, 0.167801103, 0.147042441, 0.125313864, 0.101470305, 0.103761519, 0.11597319, 0.107052417, 0.0880079809}, {0.0435778469, 0.167800486, 0.147041951, 0.125313914, 0.101470076, 0.103761707, 0.115973611, 0.107052756, 0.0880076518}, {0.0435786417, 0.16779926, 0.147042119, 0.125313391, 0.101470554, 0.103762378, 0.115973792, 0.107052537, 0.0880073289}, {0.043581505, 0.167797871, 0.147043608, 0.125312521, 0.101469081, 0.103762173, 0.115973414, 0.107054363, 0.0880054639}, {0.0435811435, 0.167798952, 0.147043687, 0.125312616, 0.101468918, 0.103762052, 0.115973417, 0.107053968, 0.0880052462}, {0.0435812603, 0.167798873, 0.147044518, 0.125312321, 0.101468879, 0.103761729, 0.115972692, 0.107054049, 0.0880056789}, {0.0435808733, 0.167799002, 0.147044529, 0.125312675, 0.101468951, 0.103761472, 0.115972643, 0.107053883, 0.0880059719}, {0.0435807283, 0.167799231, 0.14704464, 0.12531292, 0.101468814, 0.103761275, 0.115972628, 0.107053662, 0.088006103} };

There are far too many values to comprehend. Our first reaction after seeing so much noise might be to simply ignore it and continue reading further. But what does it really mean?

We could find the answer of this relatively simply — by plotting the values and seeing how they relate. For this, we replace "{" with "[" and "}" with "]" and wrap the whole in the Numpy's array function. For each sequence of values we plot with another color (here grayscale for simplicity).

import numpy as np import matplotlib.pyplot as plt vec = array([[0.0435820277, 0.167794347, 0.147040722, 0.125310654, 0.10147112, 0.10376347, 0.115973878, 0.107056197, 0.0880075845], [0.0435817033, 0.167795985, 0.1470426, 0.125311016, 0.101470666, 0.103763084, 0.115972864, 0.107055437, 0.0880066471], [0.0435798639, 0.167797087, 0.147042073, 0.125313291, 0.101470979, 0.103761847, 0.115973234, 0.107054351, 0.0880072753], [0.043578895, 0.167797426, 0.147041988, 0.125313875, 0.101470922, 0.103761581, 0.115973137, 0.107054001, 0.0880081751], [0.0435786725, 0.167797743, 0.1470428, 0.125313553, 0.101470946, 0.103761391, 0.115973188, 0.10705364, 0.0880080663], [0.0435779307, 0.167797788, 0.147042734, 0.125314068, 0.101471449, 0.10376142, 0.115973187, 0.107053473, 0.0880079505], [0.043576761, 0.167801375, 0.147042624, 0.125314075, 0.101470546, 0.103761069, 0.115973226, 0.107051966, 0.0880083593], [0.0435771819, 0.167801103, 0.147042441, 0.125313864, 0.101470305, 0.103761519, 0.11597319, 0.107052417, 0.0880079809], [0.0435778469, 0.167800486, 0.147041951, 0.125313914, 0.101470076, 0.103761707, 0.115973611, 0.107052756, 0.0880076518], [0.0435786417, 0.16779926, 0.147042119, 0.125313391, 0.101470554, 0.103762378, 0.115973792, 0.107052537, 0.0880073289], [0.043581505, 0.167797871, 0.147043608, 0.125312521, 0.101469081, 0.103762173, 0.115973414, 0.107054363, 0.0880054639], [0.0435811435, 0.167798952, 0.147043687, 0.125312616, 0.101468918, 0.103762052, 0.115973417, 0.107053968, 0.0880052462], [0.0435812603, 0.167798873, 0.147044518, 0.125312321, 0.101468879, 0.103761729, 0.115972692, 0.107054049, 0.0880056789], [0.0435808733, 0.167799002, 0.147044529, 0.125312675, 0.101468951, 0.103761472, 0.115972643, 0.107053883, 0.0880059719], [0.0435807283, 0.167799231, 0.14704464, 0.12531292, 0.101468814, 0.103761275, 0.115972628, 0.107053662, 0.088006103]]) subvec_len = len(vec[0]) subvec_range = range(subvec_len) colors = np.linspace(0,255,subvec_len).astype(int) for v, clr in zip(vec, colors): hex_str = "0%X" if clr < 10 else "%X" c = "#" + (hex_str % (clr,)) * 3 plt.plot(subvec_range, v, '-', color=c) plt.show()

This gives us the following plot, where the overlap in our colors doesn't allow us to see the line more clearly. What these numbers represent then is something dynamic that initially grows very rapidly, then falls down more slowly, reaches a plateau, grows a bit and then falls further. There is a tiny band within which all subsequences exist and which they do not escape. It took us only five minutes to see this.

Line defined by the points in the C++ code