Statistics calculator of a series in O(1) space complexity
Project description
Streaming statistics calculator
This tool allows users to calculate statistical features such as mean, median, variance, standard deviation, and skewness, along with the minimum and maximum of a series of numbers in real time without storing them. It can calculate all these features in O(1) space complexity.
This is very useful when dealing with large series of numbers on a resource contrained system. It uses different mathematical logic to keep track of certain variables for its functioning.
Installation
pip install streaming-stats
Execution
from streaming_stats import StreamingStats
example_series = [4.45, -2, 7.1, -8.7, 3, -2, 45, ,6, -12.3, 53.6, 2.7, 0, 3.6]
object = StreamingStats()
for number in example_series:
object.update(number)
print(object.get_mean())
print(object.get_median())
print(object.get_std())
print(object.get_variance())
print(object.get_min())
print(object.get_max())
print(object.get_skewness())
Other features of the tool includes merging of two different StreamingStats objects. There can be situation when users would need to find variance (suppose) of the combined series. The merge() method helps in achieving the same.
object1 = StreamingStats()
object2 = StreamingStats()
for number in series1:
object1.update(number)
for number in series2:
object.update(number)
merged_object = object1.merge(object2)
print(merged_object.get_mean())
print(merged_object.get_median())
print(merged_object.get_std())
print(merged_object.get_variance())
print(merged_object.get_min())
print(merged_object.get_max())
print(merged_object.get_skewness())
Note that the
example_serieslist was created just for demonstration. Users don't need to have the numbers of the series stored anywhere. The numbers can be added to theStreamingStatsobject as soon as it is recieved.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streaming_stats-0.3.tar.gz.
File metadata
- Download URL: streaming_stats-0.3.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3caad1cf211aa5caf7baad3c11041c097579b24ca078df61c8fd81b3548d4318
|
|
| MD5 |
3836191a112ac20dacf93cdf30b983a5
|
|
| BLAKE2b-256 |
ec4dc84bc48da6c6b1609cb6552488652012f820fc0f6dce59c37c1a61674c78
|
File details
Details for the file streaming_stats-0.3-py3-none-any.whl.
File metadata
- Download URL: streaming_stats-0.3-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
783e29960d5000e0f58e4e49eb9021cfd5ec98bb97d3fbd43575cc569d7ad516
|
|
| MD5 |
2d31f8d7b4ef9caa8c6500701be92372
|
|
| BLAKE2b-256 |
f0ead6b5521f9201efb4cc6ff23544e497019a9531686862e360d64da531ad79
|