mathx
arrange()
Returns array of numbers.
Syntax
arrange(start, end, step)Parameters
startNumberstart fromendNumberend tostepNumberincrements
Return value
Number[] generated numbers in an array.
Usage example
| |
linspace()
Returns array of numbers.
Syntax
linspace(start, end, count)Parameters
startNumberstart fromendNumberend tocountNumbertotal count of numbers to generate
Return value
Number[] generated numbers in an array.
Usage example
| |
meshgrid()
Returns array of numbers array.
Syntax
meshgrid(arr1, arr2)Parameters
arr1Number[]arr2Number[]
Return value
Number[][] generated numbers in an array of numbers.
Usage example
| |
sort()
The sort function sorts the elements of an array in ascending order.
It is useful for organizing data or preparing it for further analysis.
Usage example
| |
sum()
The sum function calculates the total sum of all numbers in an array.
It is commonly used in statistical and mathematical computations.
Usage example
| |
cdf()
The cdf function calculates the cumulative distribution function (CDF) for a given dataset x
that is the fraction of the samples less than or equal to q.
It represents the probability that a random variable takes on a value less than or equal to a specified value.
This function is commonly used in statistical analysis and probability theory to understand the distribution of data.
Syntax
cdf(q, x, weights)qNumberxNumber[]Thexdata must be sorted in increasing order.weightsNumber[]If weights is not specified then all of the weights are 1. If weights is specified, then length ofxmust equal length ofweights.
Usage example
| |
mean()
The mean function calculates the arithmetic mean (average) of a given array of numbers.
It is computed by summing all the elements in the array and dividing by the total number of elements.
This function is commonly used in statistical analysis to determine the central tendency of a dataset.
Usage example
| |
circularMean()
The circularMean function calculates the mean of angles measured in radians, taking into account the circular nature of angles.
It is particularly useful for datasets where values wrap around, such as angles or time of day.
Optionally, weights can be provided to compute a weighted circular mean.
Usage example
| |
correlation()
The correlation function calculates the Pearson correlation coefficient between two datasets.
It measures the linear relationship between the datasets,
with values ranging from -1 (perfect negative correlation) to 1 (perfect positive correlation).
Optionally, weights can be provided to compute a weighted correlation.
Usage example
| |
covariance()
The covariance function calculates the covariance between two datasets.
Covariance is a measure of how much two random variables vary together.
A positive covariance indicates that the variables tend to increase together,
while a negative covariance indicates that one variable tends to increase as the other decreases.
Usage example
| |
entropy()
The entropy function calculates the Shannon entropy of a probability distribution.
Entropy is a measure of uncertainty or randomness in the distribution.
It is commonly used in information theory and statistics.
Usage example
| |
geometricMean()
The geometricMean function calculates the geometric mean of a given array of positive numbers.
It is computed by multiplying all the elements in the array and then taking the nth root, where n is the total number of elements.
This function is commonly used in financial and statistical analysis to determine the average rate of return or growth.
Usage example
| |
harmonicMean()
The harmonicMean function calculates the harmonic mean of a given array of positive numbers.
It is computed as the reciprocal of the arithmetic mean of the reciprocals of the elements.
This function is particularly useful for datasets involving rates or ratios, such as speeds or densities.
Usage example
| |
median()
The median function calculates the median of a given array of numbers.
The median is the middle value when the numbers are sorted in ascending order.
If the array has an even number of elements, the median is the average of the two middle values.
This function is commonly used in statistical analysis to determine the central value of a dataset.
The input array should be sorted, otherwise it throws exception.
Usage example
| |
medianInterp()
The medianInterp function is same as median except it returns the linear interpolated value.
Usage example
| |
quantile()
The quantile function calculates the quantile of a given dataset for a specified probability.
Quantiles divide the dataset into intervals with equal probabilities, such as quartiles (4 intervals) or percentiles (100 intervals).
This function is useful for understanding the distribution of data.
Syntax
quantile(p, x, weights)pNumberxNumber[]Thexdata must be sorted in increasing order.weightsNumber[]If weights is not specified then all of the weights are 1. If weights is specified, then length ofxmust equal length ofweights.
Usage example
| |
quantileInterp()
The quantileInterp function is same as quantile except it returns the linear interpolated value.
Syntax
quantileInterp(p, x, weights)pNumberxNumber[]Thexdata must be sorted in increasing order.weightsNumber[]If weights is not specified then all of the weights are 1. If weights is specified, then length ofxmust equal length ofweights.
Usage example
| |
meanStdDev()
The meanStdDev function calculates both the mean and the standard deviation of a given array of numbers.
The mean represents the central tendency, while the standard deviation measures the spread or dispersion of the data.
This function is useful for summarizing datasets in statistical analysis.
Usage example
| |
mode()
The mode function calculates the mode of a given array of numbers.
The mode is the value that appears most frequently in the dataset.
If there are multiple modes, the function may return all of them or handle it based on implementation.
It returns {value: number, count: number}.
Syntax
mode(x, weights)xNumber[]Thexdata must be sorted in increasing order.weightsNumber[]If weights is not specified then all of the weights are 1. If weights is specified, then length ofxmust equal length ofweights.
Usage example
| |
moment()
The moment function calculates the nth moment of a dataset about a specified point.
Moments are used in statistics to describe the shape of a distribution, such as skewness (3rd moment) or kurtosis (4th moment).
Usage example
| |
stdDev()
The stdDev function calculates the standard deviation of a given array of numbers.
Standard deviation measures the amount of variation or dispersion in a dataset.
A low standard deviation indicates that the data points are close to the mean, while a high standard deviation indicates greater spread.
Usage example
| |
stdErr()
The stdErr function calculates the standard error of the mean for a given array of numbers.
The standard error measures the accuracy with which a sample mean represents the population mean.
It is computed as the standard deviation divided by the square root of the sample size.
Usage example
| |
linearRegression()
The linearRegression function performs a linear regression analysis on two datasets.
It calculates the best-fit line that minimizes the sum of squared residuals between the observed and predicted values.
This function is commonly used in predictive modeling and trend analysis.
It returns {slope: alpha, intercept: beta} where y = alpha*x + beta.
Usage example
| |
fft()
The fft function performs a Fast Fourier Transform (FFT) on a given dataset.
FFT is used to analyze the frequency components of a signal, making it useful in signal processing and data analysis.
fft(times, amplitudes)The length of times and amplitudes should be equal.