Code Monkey home page Code Monkey logo

random-number-generation's Introduction

Pseudo Random Number Generation

Models and simulations course. Pseudo random number generation programs

System requirements:

  • nodeJS. LTS is preferred
  • npm. 6 - 7

Before running any funtion, you must run npm install or npm i

This repo contains three functions to generate pseudo random numbers:

1. Central Squares

This function iterates taking the k central central number from the iteration's squeares, it can be ran by executing:

$ node cuadrados_centrales.js

Params

Param Importance Type of value Description
seed | s Mandatory number The seed value passed to the program, this will be used to create the first iteration
k Mandatory number The number of numbers that will be taken from each iteration. Seed must be lower than 10^k
stopWhenRepeated Optional 1 | 0 This will set the variable that will stop the iterations when a result loop is found. Default 1.
maxIterations Optional number This will set the maximum iterations to the program. Default 100

Example

$ node cuadrados_centrales.js --seed 304 -k 3 --stopWhenRepeated 0 --maxIterations 150

$ node cuadrados_centrales.js -s 501 -k 3

2. Central Products

This function iterates taking k central numbers from the iteration's product, it can be ran by executing:

$ node productos_centrales.js

Params

Param Importance Type of value Description
seed1 Mandatory number The frist seed value passed to the program, this will be used to create the first iteration
seed2 Mandatory number The second seed value passed to the program, this will be used to create the first iteration
k Mandatory number The number of numbers that will be taken from each iteration. Seed must be lower than 10^k
stopWhenRepeated Optional 1 | 0 This will set the variable that will stop the iterations when a result loop is found. Default 1.
maxIterations Optional number This will set the maximum iterations to the program. Default 50

Example

$ node productos_centrales.js --seed1 304 --seed2 512 -k 3 --stopWhenRepeated 0 --maxIterations 150

$ node productos_centrales.js --seed1 501 --seed2 273 -k 3

3. Mix Congruential

This function iterates using the mix congruential method, it can be ran by executing:

$ node congruencial_mixto.js

Params

Param Importance Type of value Description
seed Mandatory number The seed value passed to the program, this will be used to create the first iteration
a Mandatory number The multiplicative constant for the iteration
c Mandatory number The additive constant for the iteration
m Mandatory number The number to take the module from
stopWhenRepeated Optional 1 | 0 This will set the variable that will stop the iterations when a result loop is found. Default 1.
maxIterations Optional number This will set the maximum iterations to the program. Default 100

Example

$ node congruencial_mixto.js --seed 73 -a 65 -c 14 -m 92 --stopWhenRepeated 0 --maxIterations 150

$ node congruencial_mixto.js --seed 73 -a 65 -c 14 -m 92

Author: Nicolas Macias - Zeitgeist

random-number-generation's People

Contributors

zeittgeist 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.