{"id":17166656,"url":"https://github.com/willf/streaming_stats_ruby","last_synced_at":"2025-10-07T02:10:40.485Z","repository":{"id":52247623,"uuid":"318620316","full_name":"willf/streaming_stats_ruby","owner":"willf","description":"StreamingStats is a Ruby class that takes streaming numeric data and return descriptive statistics with minimal overhead.","archived":false,"fork":false,"pushed_at":"2024-12-10T14:34:42.000Z","size":50,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-13T12:12:43.769Z","etag":null,"topics":["ruby-gem","stats","streaming-data"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-04T19:49:12.000Z","updated_at":"2025-01-14T02:13:42.000Z","dependencies_parsed_at":"2025-02-23T15:32:50.141Z","dependency_job_id":"132ce2cd-8f4f-4e32-bc8a-68bed7f8149e","html_url":"https://github.com/willf/streaming_stats_ruby","commit_stats":null,"previous_names":["willf/streaming_stats_ruby"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/willf/streaming_stats_ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willf%2Fstreaming_stats_ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willf%2Fstreaming_stats_ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willf%2Fstreaming_stats_ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willf%2Fstreaming_stats_ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willf","download_url":"https://codeload.github.com/willf/streaming_stats_ruby/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willf%2Fstreaming_stats_ruby/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278708004,"owners_count":26031932,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ruby-gem","stats","streaming-data"],"created_at":"2024-10-14T23:06:17.860Z","updated_at":"2025-10-07T02:10:40.465Z","avatar_url":"https://github.com/willf.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Streaming Stats\n\n[![Gem Version](https://badge.fury.io/rb/streaming_stats.svg)](https://badge.fury.io/rb/streaming_stats) [![Ruby](https://github.com/willf/streaming_stats_ruby/actions/workflows/ruby.yml/badge.svg)](https://github.com/willf/streaming_stats_ruby/actions/workflows/ruby.yml)\n\nStreamingStats is a Ruby class that takes streaming numeric data\nand return descriptive statistics with minimal overhead.\nA stream with n entries will only require about log2(n) storage.\nThe main update function is `insert`, and the object can\nreturn:\n\n- n (number of values inserted)\n- sum\n- mean\n- stddev\n- variance\n- quantile (i.e. percentile)\n- min\n- max\n\nNote that quantiles are approximate.\n\n```irb\nrequire 'streaming_stats'\n\u003e gk = StreamingStats.new(epsilon: 0.01)\n\u003e 10000.times {gk.insert rand}\n=\u003e 10000\n\u003e gk.n\n=\u003e 10000\n\u003e gk.sum\n=\u003e 4985.484627445102\n\u003e gk.mean\n=\u003e 0.4985484627445139\n\u003e gk.stddev\n=\u003e 0.288236161831176\n\u003e gk.variance\n=\u003e 0.08308008498716787\n\u003e gk.min\n=\u003e 0.0001414880872682156\n\u003e gk.max\n=\u003e 0.9999396732975679\n\u003e gk.quantile 0.1\n=\u003e 0.08869274826771956\n\u003e gk.quantile 0.5\n=\u003e 0.4944707523857559\n\u003e gk.quantile 0.9\n=\u003e 0.9004683944698589\n\u003e gk.quantile 0.999\n=\u003e 0.9999396732975679\ngk.compression_ratio\n=\u003e 0.9927\n```\n\nThe basic stats (n, sum, mean, variance, stddev) are from\nmy very first Gist: https://gist.github.com/willf/187846.\n\nThe approximate quartile method is a port of [streaming-percentiles-js](https://github.com/sengelha/streaming-percentiles-js).\n\nHow to calculate streaming percentiles is discussed in Steven Englehardt's series, [Calculating Percentiles on Streaming Data](https://www.stevenengelhardt.com/series/calculating-percentiles-on-streaming-data/).\n\n## Script version\n\nThere is also a script version, which will take read numbers from STDIN and produce results on a regular basis:\n\n```\n$ bin/streaming_stats --help\nPrints streaming stats from numbers in $STDIN\n  -help, -h:\n     show help\n  --every x, -n x:\n     display stats every x numbers. default: 5\n```\n\nFor example:\n\n```\n$ ping 8.8.8.8 | ack -oh '\\d+\\.\\d{2,}' --flush | bin/streaming_stats -n 10\nn       v       μ       σ       min     max     p99\n10      16.99   19.77   2.61    16.99   26.43   21.36\n20      25.19   20.56   2.87    16.99   27.13   26.43\n^C\n22      19.01   20.4    2.79    16.99   27.13   26.43\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillf%2Fstreaming_stats_ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillf%2Fstreaming_stats_ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillf%2Fstreaming_stats_ruby/lists"}