GithubHelp home page GithubHelp logo

ne-sachirou / stream_stat Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 53 KB

StreamStat: Aggregate large data statictics with streaming.

License: GNU General Public License v3.0

Ruby 100.00%
data-statictics

stream_stat's Introduction

StreamStat: Aggregate large data statictics with streaming.

Gem Version Dependency Status Build Status Code Climate Test 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.

# Monkey patch
module Enumerable
  def last
    inject { |_a, v| v }
  end
end

large_data = (1..100_000).lazy.collect { rand 100_000 }
p StreamStat.new(large_data).last.sd

View the intermediate results.

# Monkey patch
module Enumerable
  def each_tap
    collect do |*item|
      yield(*item)
      item
    end
  end

  def last
    inject { |_a, v| v }
  end
end

def 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
end

large_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

Installation

Add this line to your application's Gemfile:

gem 'stream_stat'

And then execute:

$ bundle

Or install it yourself as:

$ gem install stream_stat

stream_stat's People

Contributors

ne-sachirou avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.