Skip to main content

My personal tools

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


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

aditya-0.1.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file aditya-0.1.tar.gz.

File metadata

  • Download URL: aditya-0.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.13

File hashes

Hashes for aditya-0.1.tar.gz
Algorithm Hash digest
SHA256 c8c9ab04657bbd54c4b94583c71d955bd662f3690c109f954f199a555d0d2a81
MD5 69f4994092b85f0700035e8e046feba9
BLAKE2b-256 5439cca3912c8905213f94d9a1b7bff74bff29341b432055def547cb8be8f758

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