1 | /**
|
2 | * We use `ε`, epsilon, as a stopping criterion when we want to iterate
|
3 | * until we're "close enough". Epsilon is a very small number: for
|
4 | * simple statistics, that number is **0.0001**
|
5 | *
|
6 | * This is used in calculations like the binomialDistribution, in which
|
7 | * the process of finding a value is [iterative](https://en.wikipedia.org/wiki/Iterative_method):
|
8 | * it progresses until it is close enough.
|
9 | *
|
10 | * Below is an example of using epsilon in [gradient descent](https://en.wikipedia.org/wiki/Gradient_descent),
|
11 | * where we're trying to find a local minimum of a function's derivative,
|
12 | * given by the `fDerivative` method.
|
13 | *
|
14 | * @example
|
15 | * // From calculation, we expect that the local minimum occurs at x=9/4
|
16 | * var x_old = 0;
|
17 | * // The algorithm starts at x=6
|
18 | * var x_new = 6;
|
19 | * var stepSize = 0.01;
|
20 | *
|
21 | * function fDerivative(x) {
|
22 | * return 4 * Math.pow(x, 3) - 9 * Math.pow(x, 2);
|
23 | * }
|
24 | *
|
25 | * // The loop runs until the difference between the previous
|
26 | * // value and the current value is smaller than epsilon - a rough
|
27 | * // meaure of 'close enough'
|
28 | * while (Math.abs(x_new - x_old) > ss.epsilon) {
|
29 | * x_old = x_new;
|
30 | * x_new = x_old - stepSize * fDerivative(x_old);
|
31 | * }
|
32 | *
|
33 | * console.log('Local minimum occurs at', x_new);
|
34 | */
|
35 | const epsilon = 0.0001;
|
36 |
|
37 | export default epsilon;
|