EPSILON | = | 0.000000001 | ||
FACTORIALS | = | [ 1, 1, 2, 6, 24, 120, 720, 5_040, 40_320, 362_880, 3_628_800, 39_916_800, 479_001_600, 6_227_020_800, 87_178_291_200, 1_307_674_368_000 | First 16 factorials. | |
INVERSE_LN_2 | = | 1.0 / ::Math.log(2.0) |
amd | -> | absolute_mean_difference |
mean | -> | mean_average |
rmd | -> | relative_mean_difference |
std | -> | standard_deviation |
The average absolute difference of two independent values drawn from the sample. Equal to the RMD * mean.
Closely related to the Theil index and easily expressible in terms of it.
AI = 1-e^{theil_index}
Levi-Civita symbol of i, j, and k - 1 if (i, j, k) is (1, 2, 3), (2, 3, 1), or (3, 1, 2), -1 if it is (1, 3, 2), (2, 1, 3), or (3, 2, 1), 0 as long as i, j, and k are all elements of {1, 2, 3}, otherwise returns nil.
Greatest common divisor of m and n, nil for non-positive numbers - gcd is computed by means of the Euclidian algorithm.
Calculates the Gini Coefficient (a measure of inequality of a distribution based on the area between the Lorenz curve and the uniform curve).
en.wikipedia.org/wiki/Gini_coefficient
This is a slightly cleaner way of calculating the Gini Coefficient then the previous implementationj.
GC = \frac{\sum_{i=1}^N (2i-N-1)x_i}{N^2-\bar{x}}
The Kullback-Leibler divergence from this array to that of q.
NB: You will possibly want to sort both P and Q before calling this depending on what you‘re actually trying to measure.
Least common multiple of m and n, computed by multiplying m and n and dividing the product by the gcd of m and n, nil for non-positive numbers.
Returns real solution(s) of +a+x + b = c or nil if no or an infinite number of solutions exist. If c is missing it is assumed to be 0.
Calculates the relative mean difference of this sample. Makes use of the fact that the Gini Coefficient is half the RMD.
Returns array of real solution of ax**2 + bx + c = d or nil if no or an infinite number of solutions exist. If d is missing it is assumed to be 0.
In order to solve ax**2 + bx + c = d +Extmath.sqsolve+ identifies several cases:
The equation to be solved actually is a second order one. * <code>c == d</code> The equation to be solved is <code>ax**2 + bx = 0</code>. One solution of this equation obviously is <code>x = 0</code>, the second one solves <code>ax + b = 0</code>. The solution of the latter is delegated to +Extmath.linsolve+. An array containing both results in ascending order is returned. * <code>c != d</code> The equation cannot be separated into <code>x</code> times some factor. * <code>b == 0</code> The equation to be solved is <code>ax**2 + c = d</code>. This can be written as the linear equation <code>ay + c = d</code> with <code>y = x ** 2</code>. The solution of the linear equation is delegated to +Extmath.linsolve+. If the returned value for +y+ is +nil+, that becomes the overall return value. Otherwise an array containing the negative and positive squareroot of +y+ is returned * <code>b != 0 </code> The equation cannot be reduced to simpler cases. We now first have to compute what is called the discriminant <code>x = b**2 + 4a(d - c)</code> (that's what we need to compute the square root of). If the descriminant is negative no real solution exists and <code>nil</code> is returned. The ternary operator checking whether <code>b</code> is negative does ensure better numerical stability --only one of the two solutions is computed using the widely know formula for solving second order equations. The second one is computed from the fact that the product of both solutions is <code>(c - d) / a</code>. Take a look at a book on numerical mathematics if you don't understand why this should be done.
Returns sum. When a block is given, summation is taken over the each result of block evaluation.
Calculates the Theil index (a statistic used to measure economic inequality).
TI = \sum_{i=1}^N \frac{x_i}{\sum_{j=1}^N x_j} ln \frac{x_i}{\bar{x}}
http://en.wikipedia.org/wiki/Theil_index
Variance of the sample. Variance of 0 or 1 elements is 0.0.
TODO: Same as variance? Then choose one.