Standard Deviation

Degenerate distribution standard deviation.

The variance for a degenerate random variable is

upper S upper D left-parenthesis upper X right-parenthesis equals 0

where μ is the constant value of the distribution.

Usage

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 NaN

Examples

var randu = require( '@stdlib/random/base/randu' );
var stdev = require( '@stdlib/stats/base/dists/degenerate/stdev' );

var mu;
var v;
var i;

for ( i = 0; i < 10; i++ ) {
    mu = randu();
    v = stdev( mu );
    console.log( 'µ: %d, SD(X;µ): %d', mu.toFixed( 4 ), v.toFixed( 4 ) );
}

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.0

The function accepts the following arguments:

  • mu: [in] double constant 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( "mu: %lf, SD(X;µ): %lf \n", mu, result );
    }
}
Did you find this page helpful?