From 9cb15ca79df8a28231cb600b2898835ba1b22c25 Mon Sep 17 00:00:00 2001 From: Alexey Kiselev Date: Sat, 30 Nov 2019 16:23:38 +0000 Subject: [PATCH] Readme refactored --- Readme.md | 44 +++++++++++++++++++++++++++++++++--- core/methods/extremevalue.js | 2 +- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/Readme.md b/Readme.md index c975324..b8e597a 100644 --- a/Readme.md +++ b/Readme.md @@ -6,14 +6,44 @@ A JavaScript module for generating seeded random distributions and its statistic Implemented in pure JavaScript with no dependencies, designed to work in Node.js and fully asynchronous, tested *with 600+ tests*. -[Supported distributions](./core/methods/) +#### [Supported distributions](./core/methods/) + +| Name | Parameters | Usage | +| --- | --- | --- | +| Uniform distribution | `min` - any value, `max` - any value, `min` < `max` | `unirand.uniform(min, max).random()` | +| Normal (Gaussian) distribution | `mu` - any value, `sigma` > 0 | `unirand.normal(mu, sigma).random()` | +| Bates distribution | `n` - integer, `n` >= 1, `a` - any value, `b` - any value, `b` > `a` | `unirand.bates(n, a, b).random()` | +| Bernoulli distribution | `p` - float number, 0 <= `p` <= 1 | `unirand.bernoulli(p).random()` | +| Beta distribution | `alpha` - integer, `alpha` > 0, `beta` > integer, `beta` > 0 | `unirand.beta(alpha, beta).random()` | +| BetaPrime distribution | `alpha` - integer, `alpha` > 0, `beta` > integer, `beta` > 0 | `unirand.betaprime(alpha, beta).random()` | +| Binomial distribution | `n` - integer, `n` > 0, `p` - float number, 0 <= `p` <= 1 | `unirand.binomial(n, p).random()` | +| Cauchy (Lorenz) distribution | `x` - any value, `gamma` > 0 | `unirand.cauchy(x, gamma).random()` | +| Chi distribution | `k` - integer, `k` > 0 | `unirand.chi(k).random()` | +| Chi Square distribution | `k` - integer, `k` > 0 | `unirand.chisquare(k).random()` | +| Erlang distribution | `k` - integer, `k` > 0, `mu` - float value, `mu` > 0 | `unirand.erlang(k, mu).random()` | +| Exponential distribution | `lambda` - float value, `lambda` > 0 | `unirand.exponential(lambda).random()` | +| Extreme (Gumbel-type) Value distribution | `mu` - any value, `sigma` - float number, `sigma` > 0 | `unirand.extremevalue(mu, sigma).random()` | +| Gamma distribution | `alpha` - float value, `alpha` > 0, `beta` - integer, `beta` > 0 | `unirand.gamma(alpha, beta).random()` | +| Geometric distribution | `p` - float value, 0 <= `p` <= 1 | `unirand.geometric(p).random()` | +| Irwin-Hall distribution | `n` - integer, `n` > 0 | `unirand.irwinhall(n).random()` | +| Laplace distribution | `mu` - any value, `b` - float value, `b` > 0 | `unirand.laplace(mu, b).random()` | +| Logistic distribution | `mu` - any value, `s` - float value, `s` > 0 | `unirand.logistic(mu, s).random()` | +| Lognormal distribution | `mu` - any value, `sigma` - float value, `sigma` > 0 | `unirand.lognormal(mu, sigma).random()` | +| Negative Binomial distribution | `r` - integer, `r` > 0, `p` - float value, 0 <= `p` <= 1 | `unirand.negativebinomial(r, p).random()` | +| Pareto distribution | `xm` - float value, `xm` > 0, `alpha` - float value, `alpha` > 0 | `unirand.pareto(xm, alpha).random()` | +| Poisson distribution | `lambda` - integer, `lambda` > 0 | `unirand.poisson(lambda).random()` | +| Rayleigh distribution | `sigma` - float value, `sigma` > 0 | `unirand.rayleigh(sigma).random()` | +| Student's t-distribution | `v` - integer, `v` > 0 | `unirand.student(v).random()` | +| Triangular distribution | `a`, `b`, `c` - any number, `b` > `a`, `a` <= `c` <= `b` | `unirand.triangular(a, b, c).random()` | +| Weibull distribution | `k` - float value, `k` > 0, `lambda` - float value, `lambda` > 0 | `unirand.weibull(k, lambda).random()` | +| Zipf distribution | `alpha` - float value, `alpha` >= 0, `shape` - integer, `shape` > 1 | `unirand.zipf(alpha, shape).random()` | ## Installation and Usage Install the `unirand` module, using `npm install unirand`, then include the code with require. The `require` method returns an object with all of the module's methods attached to it. ```javascript -const unirand = require('unirand') +const unirand = require('unirand'); ``` ### PRNG @@ -133,9 +163,17 @@ unirand.utils.erf(2); // returns error function with argument 2 ### Hash Returns *hash* using murmur3 algorithm ```javascript -unirand.hash('unirand'); +unirand.hash('unirand'); // string input +// or +unirand.hash(123456); // numerical input ``` +Also supports different `seed values`. By default, `seed` value is zero. + +```javascript +unirand.hash('unirand', 123); +``` + ### Sample Generates **random sample** from array, string or object. This method will generate *k* random elements from array/string with *n* elements. ```javascript diff --git a/core/methods/extremevalue.js b/core/methods/extremevalue.js index 632c6ae..6184360 100644 --- a/core/methods/extremevalue.js +++ b/core/methods/extremevalue.js @@ -7,7 +7,7 @@ * @param mu - location, any value * @param sigma - scale, sigma > 0 * @returns Extreme Value distributed numbers - * Created by Alexey S. Kiselev on 27.11.2017. + * Created by Alexey S. Kiselev */ import type { MethodError, RandomArray } from '../types';