Data Containers |
The Financial Analysis library provides several base data container specialized to effectively operate and manipulate with time series data.
Here is a simple algorithm to choose the data collection for your purposes.
Note |
---|
You can use a combination of listeners for the collection. In some cases we suggest using other collections: Min Max Queue class is good if you need only Min/Max value on sliding window. If you need only sum on interval or intervals within sliding window you can use Ultimate Summator. |
Note |
---|
Min Max Queue class and Ultimate Summator do not support manual PushLast/RemoveFirst operations. They also do not allow access to data by index. |
Here follows the table, showing asymptotic performance for each case.
Operation | Distribution class | Simple Data Queue without listener | Simple Data Queue w/Distribution listener | Simple Data Queue w/Statistics listener | Simple Data Queue w/Maximizer /Minimizer listener |
---|---|---|---|---|---|
PushLast/RemoveFirst | O(log N) | O(1) | O(log N) | O(1) | O(1) |
Min/Max | O(log N) | n/a | O(log N) | n/a | O(1) |
Sum, SumOfSquares, SumOfAbsoluteValues, (various) First and Second Moment, (various) Means, (various) StdDevs/Variance | O(1) | O(1) | O(1) | O(1) | n/a |
Third and Fourth moment, Kurtosis, Skewness | O(1) | n/a | O(1) | O(1) | n/a |
OrderStatistics, Quantile, Cdf | O(log N) | n/a | O(log N) | n/a | n/a |
Note |
---|
Both Distribution and Distribution Listener classes use AVL Tree in order to optimize calculations of quantiles, order statistics, CDF, min/max. |
Note |
---|
There is limit in IDataQueue elements, it's 2^31 bytes (~2 gigabytes) or 250 000 000 elements. It's limitation on array size in .Net platform. For AVL tree pushing new element and complex statistics (such as quantiles, order statistics, CDF, min/max.) calculation time is O(log N) regarding to AVL tree, ie ~28*c operation for update in worst case, we don't need to iterate entire data series neither on insertion neither on statistics calculation. |