deno.land / x / simplestatistic@v7.7.1 / src / epsilon.js

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

Version Info

Tagged at
2 years ago