Time to do the real world after all data inputs available in the quality needed. Use the full B4P capabilities and function libraries such as statistics functions to analyze the data and draw meaningful conclusions. The functions listed below could be of interest, but check the function library first before implementing something wtih low level code such as individual calculations..
table serialize() | Serialize data where values are spread horizontally, e.g. by quarterse and years to a pure sequential list. |
table spread() | Spread sequential data horizontally, e.g. by month and year in separate columns. |
table consolidate() | Condense the data and apply algorithms on the values to condense, e.g. adding up, taking maximum, etc. |
table transpose() | Exchange rows with columns. |
table rotate left() table rotate right() | Rotate table contents |
table flip horizontally() table flip vertically() | Flip, i.e. mirror table contents |
Below you find a selection of statistics functions. B4P provides a large collection of functions able to fulfill your analytical needs.
table histogram() | Create 1- or 2-dimensional histograms |
table distribute() | Very useful for production planning. |
linear interpolation() | Do linar interpolation for missing points |
cagr() | Calculate compound average growth rate |
discount() | Calculate discounted cash flow, i.e. net present value (NPV) |
average(), deviation() | Calculate average and standard deviation of a set of values |
covariance(), correlation() | Covariance and correlation |
gini() | Calculate gini coefficient (and Lorenz curve) on income inequality |
Do some validation on this table:
// Create a histogram distribution across number of inhabitants and density
intervals[inhabitants]
= { 1000000, 2000000, 5000000, 10000000, 20000000, 50000000, 100000000, 200000000, 500000000, 1000000000 };
intervals[density] = { 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000 };
intervals[] = { intervals[inhabitants], intervals[density] }; // Combine them in 1 set
table histogram ( c1, histo, {Population,Inhabitants per km2}, intervals[] );
table process selected rows ( histo, is numeric([Intervals]), [Intervals] = ">=" + str([Intervals], "#,##0", local ) );
table process selected columns ( histo, 0, is numeric([.]), [.] = ">=" + str([.], "#,##0", local ) );
// Remove the 'Others' as not needed.
table delete columns ( histo, Others );
table delete selected rows ( histo, [Intervals]=Others );
// Provide consolidated info by continent
table copy table ( c1, c2 );
table consolidate ( c2, Continent, { Area, Population}, sum); // Consolidate by continent
table process ( c2, [Inhabitants per km2] = [Inhabitants] / [Area];
[Inhabitants Variation] = ([Inhabitants] - [Population])/[Inhabitants];
[Country] = "All countries in " + [Continent] );
for all ( {c1, c2}, table[]) table delete columns( table[], Inhabitants);
table merge ( c2, c1 );
echo("Histogram generated:");
table list ( histo );
Histogram generated:
0 : Intervals | Below | >=10 | >=20 | >=50 | >=100 | >=200 | >=500 | >=1'000 | >=2'000 | >=5'000 | >=10'000
1 : Below | 3 | 2 | 7 | 3 | 7 | 13 | 1 | 1 | 1 | 0 | 0
2 : >=1'000'000 | 0 | 0 | 3 | 4 | 2 | 1 | 1 | 1 | 0 | 0 | 0
3 : >=2'000'000 | 4 | 0 | 3 | 7 | 3 | 4 | 0 | 0 | 0 | 0 | 0
4 : >=5'000'000 | 3 | 7 | 4 | 4 | 7 | 3 | 2 | 0 | 0 | 1 | 0
5 : >=10'000'000 | 0 | 3 | 5 | 9 | 8 | 5 | 1 | 0 | 0 | 0 | 0
6 : >=20'000'000 | 3 | 4 | 6 | 11 | 6 | 3 | 1 | 0 | 0 | 0 | 0
7 : >=50'000'000 | 0 | 0 | 3 | 4 | 4 | 2 | 1 | 0 | 0 | 0 | 0
8 : >=100'000'000 | 1 | 0 | 1 | 1 | 2 | 3 | 0 | 1 | 0 | 0 | 0
9 : >=200'000'000 | 0 | 0 | 2 | 0 | 1 | 2 | 0 | 0 | 0 | 0 | 0
10 : >=500'000'000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
11 : >=1'000'000'000 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0