Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ne-sachirou/stream_stat
StreamStat: Aggregate large data statictics with streaming.
https://github.com/ne-sachirou/stream_stat
data-statictics
Last synced: 4 days ago
JSON representation
StreamStat: Aggregate large data statictics with streaming.
- Host: GitHub
- URL: https://github.com/ne-sachirou/stream_stat
- Owner: ne-sachirou
- License: gpl-3.0
- Created: 2016-10-06T12:58:12.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-17T14:11:59.000Z (over 1 year ago)
- Last Synced: 2024-10-02T08:14:01.596Z (about 1 month ago)
- Topics: data-statictics
- Language: Ruby
- Size: 51.8 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
StreamStat: Aggregate large data statictics with streaming.
[![Gem Version](https://badge.fury.io/rb/stream_stat.svg)](https://badge.fury.io/rb/stream_stat)
[![Dependency Status](https://gemnasium.com/badges/github.com/ne-sachirou/stream_stat.svg)](https://gemnasium.com/github.com/ne-sachirou/stream_stat)
[![Build Status](https://travis-ci.org/ne-sachirou/stream_stat.svg?branch=master)](https://travis-ci.org/ne-sachirou/stream_stat)
[![Code Climate](https://codeclimate.com/github/ne-sachirou/stream_stat/badges/gpa.svg)](https://codeclimate.com/github/ne-sachirou/stream_stat)
[![Test Coverage](https://codeclimate.com/github/ne-sachirou/stream_stat/badges/coverage.svg)](https://codeclimate.com/github/ne-sachirou/stream_stat/coverage)StreamStat
==
A library to aggragate statistics of large data with streaming, less memory.Currently supported are:
- average 平均 `:avg`
- variance 分散 `:variance`
- standard deviation 標準偏差 `:sd`
- minimun 最小値 `:min`
- maximum 最大値 `:max`Usage
--Aggragate a SD of large_data.
```ruby
# Monkey patch
module Enumerable
def last
inject { |_a, v| v }
end
endlarge_data = (1..100_000).lazy.collect { rand 100_000 }
p StreamStat.new(large_data).last.sd
```View the intermediate results.
```ruby
# Monkey patch
module Enumerable
def each_tap
collect do |*item|
yield(*item)
item
end
enddef last
inject { |_a, v| v }
end
enddef pstat(stat)
puts <<-EOF
avg:\t#{stat.avg}
variance:\t#{stat.variance}
sd:\t#{stat.sd}
min:\t#{stat.min}
max:\t#{stat.max}
EOF
endlarge_data = (1..100_000).lazy.collect { rand 100_000 }
stat = StreamStat.new(large_data)
.lazy
.each_with_index
.each_tap { |st, i| pstat st if (i % 10_000).zero? }
.last[0]
pstat stat
```[doc](http://www.rubydoc.info/gems/stream_stat)
Installation
--
Add this line to your application's Gemfile:```ruby
gem 'stream_stat'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install stream_stat