GithubHelp home page GithubHelp logo

fricto / normalrandomgenerator Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 112 KB

A JavaScript class that defines a generator for normally (gaussian) distributed random numbers, either singly or in sets (arrays). AMD compliant.

License: MIT License

JavaScript 100.00%

normalrandomgenerator's Introduction

#normalRandomGenerator.js


normalRandomGenerator is a module that generates random numbers in a normally (gaussian) distributed set.

##Initialization The constructor function is called normalRandom(). var myNormalRandomGenerator = new normalRandom(); The constructor function takes two optional parameters. -stdev {number} The standard deviation for the set (default: 1). -mean {number} The mean for the set (default: 0). The class defines a reset() method which takes the same optional parameters. This method clears the cache of values from the set and resets the mean and standard deviation for the set. If no parameters are passed to it, the mean and standard deviation are reset to the defaults (0 and 1, respectively).

##Generating Values The class defines a get() method which returns values from the set defined at initialization. var myNormalRandomGenerator = new normalRandom(); var randomNumber = myNormalRandomGenerator.get(); // returns a single value If this method is called without a parameter, it returns a single value (number). Optionally, the get() method accepts a single parameter - a number (integer) count that indicates the number of results to return. If this parameter is set to any value greater than 1, the method returns an array of values of that length. var myNormalRandomGenerator = new normalRandom(); var randomNumber = myNormalRandomGenerator.get(5); // returns an array of 5 values

##AMD Support normalRandomGenerator supports AMD. If the class is defined in the presence of a define() function, it will be used to define a module. Otherwise, it will be accessible at window scope. The AMD module returns a constructor function which can be used within other modules.

##About the Math This class generates normally distributed random numbers using the Box-Muller Transform. I am not a mathematician and do not understand the math, but you can read about it on wikipedia and explain it to me over beers.

##Version History ###0.0.1 2013.11.22 First release. Generates random numbers in pairs and returns either a single value or an array of specified length. Still needs testing, and the grunt jobs need validated, and needs unit tests.

normalrandomgenerator's People

Contributors

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