Skip to main content

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_series list was created just for demonstration. Users don't need to have the numbers of the series stored anywhere. The numbers can be added to the StreamingStats object as soon as it is recieved.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streaming_stats-0.3.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streaming_stats-0.3-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

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

Hashes for streaming_stats-0.3.tar.gz
Algorithm Hash digest
SHA256 3caad1cf211aa5caf7baad3c11041c097579b24ca078df61c8fd81b3548d4318
MD5 3836191a112ac20dacf93cdf30b983a5
BLAKE2b-256 ec4dc84bc48da6c6b1609cb6552488652012f820fc0f6dce59c37c1a61674c78

See more details on using hashes here.

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

Hashes for streaming_stats-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 783e29960d5000e0f58e4e49eb9021cfd5ec98bb97d3fbd43575cc569d7ad516
MD5 2d31f8d7b4ef9caa8c6500701be92372
BLAKE2b-256 f0ead6b5521f9201efb4cc6ff23544e497019a9531686862e360d64da531ad79

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page