File tree Expand file tree Collapse file tree 3 files changed +8
-22
lines changed
lib/node_modules/@stdlib/stats/base/dists/chi/stdev Expand file tree Collapse file tree 3 files changed +8
-22
lines changed Original file line number Diff line number Diff line change 2020
2121// MODULES //
2222
23- var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
24- var mean = require ( '@stdlib/stats/base/dists/chi/mean' ) ;
2523var sqrt = require ( '@stdlib/math/base/special/sqrt' ) ;
24+ var variance = require ( '@stdlib/stats/base/dists/chi/variance' ) ;
2625
2726
2827// MAIN //
@@ -50,12 +49,7 @@ var sqrt = require( '@stdlib/math/base/special/sqrt' );
5049* // returns NaN
5150*/
5251function stdev ( k ) {
53- var mu ;
54- if ( isnan ( k ) || k < 0.0 ) {
55- return NaN ;
56- }
57- mu = mean ( k ) ;
58- return sqrt ( k - ( mu * mu ) ) ;
52+ return sqrt ( variance ( k ) ) ;
5953}
6054
6155
Original file line number Diff line number Diff line change 3939 "libpath" : [],
4040 "dependencies" : [
4141 " @stdlib/math/base/napi/unary" ,
42- " @stdlib/math/base/assert/is-nan" ,
4342 " @stdlib/math/base/special/sqrt" ,
44- " @stdlib/stats/base/dists/chi/mean "
43+ " @stdlib/stats/base/dists/chi/variance "
4544 ]
4645 },
4746 {
5655 "libraries" : [],
5756 "libpath" : [],
5857 "dependencies" : [
59- " @stdlib/math/base/assert/is-nan" ,
6058 " @stdlib/math/base/special/sqrt" ,
61- " @stdlib/stats/base/dists/chi/mean "
59+ " @stdlib/stats/base/dists/chi/variance "
6260 ]
6361 },
6462 {
7371 "libraries" : [],
7472 "libpath" : [],
7573 "dependencies" : [
76- " @stdlib/math/base/assert/is-nan" ,
7774 " @stdlib/math/base/special/sqrt" ,
78- " @stdlib/stats/base/dists/chi/mean "
75+ " @stdlib/stats/base/dists/chi/variance "
7976 ]
8077 }
8178 ]
Original file line number Diff line number Diff line change 1616* limitations under the License.
1717*/
1818
19- #include "stdlib/stats/base/dists/chi/mean .h"
20- #include "stdlib/math /base/assert/is_nan .h"
19+ #include "stdlib/stats/base/dists/chi/stdev .h"
20+ #include "stdlib/stats /base/dists/chi/variance .h"
2121#include "stdlib/math/base/special/sqrt.h"
2222
2323/**
3131* // returns ~0.697
3232*/
3333double stdlib_base_dists_chi_stdev ( const double k ) {
34- double mu ;
35- if ( stdlib_base_is_nan ( k ) || k < 0.0 ) {
36- return 0.0 /0.0 ; // NaN
37- }
38- mu = stdlib_base_dists_chi_mean ( k );
39- return stdlib_base_sqrt ( k - ( mu * mu ) );
34+ return stdlib_base_sqrt ( stdlib_base_dists_chi_variance ( k ) );
4035}
You can’t perform that action at this time.
0 commit comments