Code Monkey home page Code Monkey logo

normcore's Introduction

Normcore

Build Status

Simple library for sampling from random distributions. Useful for testing / generating fake data.

  • Normcore::Normal - Gaussian/normal distribution.
  • Normcore::LogNormal - exp(Gaussian/normal) distribution.

Installation

RubyGems

gem install normcore

Bundler

gem 'normcore'

Usage

require 'normcore'

# μ = 0, σ = 1
d = Normcore::Normal.new(0, 1)

# return an Array of 100 samples
d.sample(100)

# get a single random value
d.rng

FactoryBot

FactoryBot.factory :measurement do
  value { Normcore::Normal.new(0, 1).rng }
end

Bonus

You can use Normcore as a command-line executable:

# produce an endless stream [defaults: μ = 0, σ = 1]
$ normcore

# μ=100, σ=50
$ normcore 100 50

Using bashplotlib:

$ normcore 1 5 | head -n 10000 | hist

 2177|        o
 2062|        oo
 1948|        oo
 1833|        oo
 1719|        oo
 1604|       ooo
 1490|       ooo
 1375|       oooo
 1261|       oooo
 1146|       oooo
 1031|       oooo
  917|       oooo
  802|      ooooo
  688|      oooooo
  573|      oooooo
  459|      oooooo
  344|     ooooooo
  230|     oooooooo
  115|     oooooooo
    1| oooooooooooooo
      --------------

-------------------------------
|           Summary           |
-------------------------------
|     observations: 10000     |
|    min value: -18.768871    |
|       mean : 0.995957       |
|     max value: 19.428214    |
-------------------------------

License

MIT (see LICENSE for details)

normcore's People

Contributors

audy avatar

Stargazers

agnė avatar

Watchers

Karsten Temme avatar  avatar James Cloos avatar

Forkers

audy

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.