by Paul Ellis
It is a library for performing some basic math and statistics calculations such as the standard deviation of an array of numbers, the product of a set of numbers, or a pseudo random number generator that generates normally distributed numbers.
Array.sample(samples)
: Returns a Array withsamples
number of random samples from the source Array. It can be used before other Array methods (e.g.myHugeArray.sample(20000).stdDev()
) to significantly improve performance while sacrificing some accuracy.Array.sum()
: Sums all values in a ArrayArray.mean()
: Returns the arithmetic mean of the source ArrayArray.median()
: Returns the the median value of the ArrayArray.percentile()
: Returns the value at the given percentile for the ArrayArray.variance()
: Returns the Variance of the source ArrayArray.stdDev()
: Returns the Standard Deviation of the source ArrayArray.max()
: Returns the highest numeric value of a ArrayArray.min()
: Returns the lowest numeric value of a ArrayArray.sortNumber(invert)
: Returns the Array sorted ascendingly, or decendingly ifinvert = true
Array.histogram()
: Returns an object where the key equals the item and the value equals the count of the times that item occured in the ArrayArray.countByType()
: Returns an object that shows the total count of each type in a Array
psMathStats extends the native Array.prototype
. Be careful if you try to loop over an array using for (var i in arr)
ps.math.even(n)
: Returns true ifn
is an even numberps.math.odd(n)
: Returns true ifn
is an odd numberps.math.fact(n)
: Calculates the factorial for any given integern
ps.math.product(n, n, n...)
: Returns the product of all of the argumentsps.math.randomBetween(floor, ceiling, digits)
: Generates a random number between two numbers, defaulting to integers (digits = 0
)ps.math.randomNormal(mean, stdDev)
: Generates normally distributed random numbers for the given mean and stardard deviation. Defaults tomean = 0
,stdDev = 1
.
ps.stats.normsinv(p)
: returns the inverse of the standard normal cumulative distribution for a givenp
percentile
BSD