Project

simpack

0.0
No commit activity in last 3 years
No release in over 3 years
A solution for all your simulation needs!
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8
~> 0.10
~> 10.0
 Project Readme

Simpack

Code Climate Test Coverage

Simpack is your go-to gem for your simulation needs in Ruby. At its heart, Simpack is a linear congruential generator (LCG) which can then be used to generate random samples from a number of statistical distributions.

Use it for simulation, modeling, or games!

Installation

Add this line to your application's Gemfile:

gem 'simpack'

And then execute:

$ bundle

Or install it yourself as:

$ gem install simpack

Usage

Simpack::LCG

#initialize

lcg = Simpack::LCG.new

Optionally, you may wish to configure your LCG to suit your preferences with an options hash:

lcg = Simpack::LCG.new({modulus: 8, multiplier: 5})

Keys for the options hash include the following:

  • :modulus
  • :multiplier
  • :increment
  • :seed

If you do decide to specify your own constants, all bets are off. Simpack (as of now) does not test for constraints of the Hull-Dobell Theorem, or any other tests of period or uniformity. This allows you to create a crappy LCG if you desire, but it will not alert you if you do.

See the Technical Specs section for details of the standard configuration.

#uniform

#uniform can be called with an optional argument specifying the number of random numbers to return.

> lcg.uniform
> 0.27662859533103207

> lcg.uniform(3)
> [0.9518568231847053, 0.7968659172399516, 0.15733885122680413]

Contributing

Want to add a new distribution? Have ideas for a feature? Spotted a bug? Contribute! I am especially looking for people who have a bit more statistical knowledge than I do to spot any potential problems with the code.

  1. Fork it ( https://github.com/johnochs/simpack/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

##Technical Specs

Simpack::LCG

Table of standard parameters:

Parameter Value
Modulus 264
Multiplier 6364136223846793005
Increment 1442695040888963407
Seed Time.now.to_i