@stdlib/stats-base-dists-degenerate-stdev
v0.3.1
Published
Degenerate distribution standard deviation.
Downloads
140
Readme
Standard Deviation
Degenerate distribution standard deviation.
The variance for a degenerate random variable is
where μ is the constant value of the distribution.
Installation
npm install @stdlib/stats-base-dists-degenerate-stdevUsage
var stdev = require( '@stdlib/stats-base-dists-degenerate-stdev' );stdev( mu )
Returns the standard deviation of a degenerate distribution with constant value mu.
var v = stdev( 10.0 );
// returns 0.0
v = stdev( -0.5 );
// returns 0.0
v = stdev( NaN );
// returns NaNExamples
var uniform = require( '@stdlib/random-array-uniform' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var stdev = require( '@stdlib/stats-base-dists-degenerate-stdev' );
var opts = {
'dtype': 'float64'
};
var mu = uniform( 10, 0.0, 1.0, opts );
logEachMap( 'µ: %0.4f, SD(X;µ): %0.4f', mu, stdev );C APIs
Usage
#include "stdlib/stats/base/dists/degenerate/stdev.h"stdlib_base_dists_degenerate_stdev( mu )
Returns the standard deviation of a degenerate distribution with constant value mu.
double out = stdlib_base_dists_degenerate_stdev( 0.1 );
// returns 0.0The function accepts the following arguments:
- mu:
[in] doubleconstant value of the distribution.
double stdlib_base_dists_degenerate_stdev( const double mu );Examples
#include "stdlib/stats/base/dists/degenerate/stdev.h"
#include <stdlib.h>
#include <stdio.h>
static double random_uniform( const double min, const double max ) {
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
return min + ( v * ( max - min ) );
}
int main( void ) {
double result;
double mu;
int i;
for ( i = 0; i < 10; i++ ) {
mu = random_uniform( -20.0, 20.0 );
result = stdlib_base_dists_degenerate_stdev( mu );
printf( "µ: %lf, SD(X;µ): %lf\n", mu, result );
}
}Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
