File tree Expand file tree Collapse file tree 3 files changed +10
-30
lines changed
lib/node_modules/@stdlib/stats/base/dists/binomial/stdev Expand file tree Collapse file tree 3 files changed +10
-30
lines changed Original file line number Diff line number Diff line change 2020
2121// MODULES //
2222
23- var isNonNegativeInteger = require ( '@stdlib/math/base/assert/is-nonnegative-integer' ) ;
24- var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
2523var sqrt = require ( '@stdlib/math/base/special/sqrt' ) ;
26- var PINF = require ( '@stdlib/constants/float64/pinf ' ) ;
24+ var variance = require ( '@stdlib/stats/base/dists/binomial/variance ' ) ;
2725
2826
2927// MAIN //
@@ -56,17 +54,7 @@ var PINF = require( '@stdlib/constants/float64/pinf' );
5654* // returns NaN
5755*/
5856function stdev ( n , p ) {
59- if (
60- isnan ( n ) ||
61- isnan ( p ) ||
62- p < 0.0 ||
63- p > 1.0 ||
64- ! isNonNegativeInteger ( n ) ||
65- n === PINF
66- ) {
67- return NaN ;
68- }
69- return sqrt ( n * p * ( 1.0 - p ) ) ;
57+ return sqrt ( variance ( n , p ) ) ;
7058}
7159
7260
Original file line number Diff line number Diff line change 3939 "libpath" : [],
4040 "dependencies" : [
4141 " @stdlib/math/base/napi/binary" ,
42- " @stdlib/math/base/assert/is-nan " ,
43- " @stdlib/math /base/special/sqrt "
42+ " @stdlib/math/base/special/sqrt " ,
43+ " @stdlib/stats /base/dists/binomial/variance "
4444 ]
4545 },
4646 {
5555 "libraries" : [],
5656 "libpath" : [],
5757 "dependencies" : [
58- " @stdlib/math/base/assert/is-nan" ,
5958 " @stdlib/math/base/special/sqrt" ,
60- " @stdlib/math/base/special/ceil"
59+ " @stdlib/math/base/special/ceil" ,
60+ " @stdlib/stats/base/dists/binomial/variance"
6161 ]
6262 },
6363 {
7272 "libraries" : [],
7373 "libpath" : [],
7474 "dependencies" : [
75- " @stdlib/math/base/assert/is-nan" ,
7675 " @stdlib/math/base/special/sqrt" ,
77- " @stdlib/math/base/special/ceil"
76+ " @stdlib/math/base/special/ceil" ,
77+ " @stdlib/stats/base/dists/binomial/variance"
7878 ]
7979 }
8080 ]
Original file line number Diff line number Diff line change 1717*/
1818
1919#include "stdlib/stats/base/dists/binomial/stdev.h"
20- #include "stdlib/math/base/assert/is_nan.h"
2120#include "stdlib/math/base/special/sqrt.h"
21+ #include "stdlib/stats/base/dists/binomial/variance.h"
2222#include <stdint.h>
2323
2424/**
3333* // returns 3.0
3434*/
3535double stdlib_base_dists_binomial_stdev ( const int32_t n , const double p ) {
36- if (
37- stdlib_base_is_nan ( p ) ||
38- n < 0 ||
39- p < 0.0 ||
40- p > 1.0
41- ) {
42- return 0.0 / 0.0 ;
43- }
44- return stdlib_base_sqrt ( n * p * (1.0 - p ) );
36+ return stdlib_base_sqrt ( stdlib_base_dists_binomial_variance ( n , p ) );
4537}
You can’t perform that action at this time.
0 commit comments