Link Search Menu Expand Document

Random

random.ts#L68

bernoulli (p: number): 0|1

Generates a Bernoulli random variable.

Name Type Default Description
p number 0.5  
random.ts#L73

binomial (n: number, p: number): number

Generates a Binomial random variable.

Name Type Default Description
n number 1  
p number 0.5  
random.ts#L115

cauchy (): number

Generates an Cauchy random variable.

random.ts#L169

chiCDF (chi: number, deg: number): number

The chi CDF function.

Name Type Default Description
chi number    
deg number    
random.ts#L104

exponential (l: number): number

Generates an exponential random variable.

Name Type Default Description
l number 1  
random.ts#L36

find (items: Array<T>): T

Randomly selects an element from an array.

Name Type Default Description
items Array<T>    
random.ts#L109

geometric (p: number): undefined|number

Generates a geometric random variable.

Name Type Default Description
p number 0.5  
random.ts#L21

integer (a: number, b: number): number

Generates a random integer between 0 and a, or between a and b.

Name Type Default Description
a number    
b number    
random.ts#L159

integrate (fn: (x: number): number, xMin: number, xMax: number, dx: number): number

Riemann-integrates fn(x) from xMin to xMax with an interval size dx.

Name Type Default Description
fn (x: number): number    
xMin number    
xMax number    
dx number 1  
random.ts#L96

normal (m: number, v: number): number

Generates a normal random variable with mean m and variance v.

Name Type Default Description
m number 0  
v number 1  
random.ts#L130

normalPDF (x: number, m: number, v: number): number

Generates pdf(x) for the normal distribution with mean m and variance v.

Name Type Default Description
x number    
m number 1  
v number 0  
random.ts#L80

poisson (l: number): number

Generates a Poisson random variable.

Name Type Default Description
l number 1  
random.ts#L11

shuffle (a: Array<T>): Array<T>

Randomly shuffles the elements in an array a.

Name Type Default Description
a Array<T>    
random.ts#L50

smart (n: number, id: string): number

Returns a random number between 0 and n, but avoids returning the same number multiple times in a row.

Name Type Default Description
n number    
id string    
random.ts#L91

uniform (a: number, b: number): number

Generates a uniform random variable.

Name Type Default Description
a number 0  
b number 1  
random.ts#L28

weighted (weights: Array<number>): number

Chooses a random index value from weights [2, 5, 3]

Name Type Default Description
weights Array<number>    

Copyright © 2021 Mathigon.org