Skip to main content

Statistics calculator of a list 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.add(number)

print(object.get_mean())
print(object.get_median())
print(object.get_std())
print(object.get_var())
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.add(number)

for number in series2:
  object.add(number)

merged_object = object1.merge(object2)

print(merged_object.mean())
print(merged_object.get_median())
print(merged_object.get_std())
print(merged_object.get_var())
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.2.tar.gz (2.7 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.2-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file streaming_stats-0.2.tar.gz.

File metadata

  • Download URL: streaming_stats-0.2.tar.gz
  • Upload date:
  • Size: 2.7 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.2.tar.gz
Algorithm Hash digest
SHA256 3ed694533e078dfd01795a83327471c8eafb5dc903fa11e64702539e26f1b067
MD5 7c0e77d3696d759802383c9999cb7c60
BLAKE2b-256 5ad23643ea2cbbaf67670fb9e28f4b61d19e8c2cb41ab3f490e9d0fb3306a4d8

See more details on using hashes here.

File details

Details for the file streaming_stats-0.2-py3-none-any.whl.

File metadata

  • Download URL: streaming_stats-0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9657dd6c2054c5e5633f760a0b9fbf5f82968fd2cc16741f47a7a04d2131c2fd
MD5 b220c63b3c101eccdbd0833bf785fe54
BLAKE2b-256 38f19c265e7c6ef6a9cec549971db9e91a932feaf544b358ab7fd01358133d09

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