standard deviation (sampled) (Descriptive Statistics)


Import

#include <archr/stats/sample_standard_deviation.h>
#include <archr/stats/sample_standard_deviation.hpp>
import archr.stats
atomsLoads('archr')

Synopsis

 float archr_stats_sample_stdevp_f32(const float *first, size_t nbelem);
(1)
 double archr_stats_sample_stdevp_f64(const double *first, size_t nbelem);
(2)
 float archr_stats_sample_stdevp2_f32(const float *first, size_t nbelem, float m);
(3)
 double archr_stats_sample_stdevp2_f64(const double *first, size_t nbelem, double m);
(4)
 float archr_stats_sample_standard_deviation_f32(const float *first, size_t nbelem);
(5)
 double archr_stats_sample_standard_deviation_f64(const double *first, size_t nbelem);
(6)
 float archr_stats_sample_standard_deviation2_f32(const float *first, size_t nbelem, float m);
(7)
 double archr_stats_sample_standard_deviation2_f64(const double *first, size_t nbelem, double m);
(8)
 float archr_stats_sample_stdev_f32(const float *first, size_t nbelem);
(9)
 double archr_stats_sample_stdev_f64(const double *first, size_t nbelem);
(10)
 float archr_stats_sample_stdev2_f32(const float *first, size_t nbelem, float m);
(11)
 double archr_stats_sample_stdev2_f64(const double *first, size_t nbelem, double m);
(12)
 float sample_stdevp(const float *first, size_t nbelem);
(1)
 double sample_stdevp(const double *first, size_t nbelem);
(2)
 float sample_stdevp(const float *first, size_t nbelem, float m);
(3)
 double sample_stdevp(const double *first, size_t nbelem, double m);
(4)
 float sample_stdevp(const float *first, const float *last);
(5)
 double sample_stdevp(const double *first, const double *last);
(6)
 float sample_stdevp(const float *first, const float *last, float m);
(7)
 double sample_stdevp(const double *first, const double *last, double m);
(8)
template <typename Range> typename Range::value_type sample_stdevp(const Range& data);
(9)
template <typename Range> typename Range::value_type sample_stdevp(const Range& data, float m);
(10)
template <typename Range> typename Range::value_type sample_stdevp(const Range& data, double m);
(11)
 float sample_stdev(const float *first, size_t nbelem);
(12)
 double sample_stdev(const double *first, size_t nbelem);
(13)
 float sample_stdev(const float *first, size_t nbelem, float m);
(14)
 double sample_stdev(const double *first, size_t nbelem, double m);
(15)
 float sample_stdev(const float *first, const float *last);
(16)
 double sample_stdev(const double *first, const double *last);
(17)
 float sample_stdev(const float *first, const float *last, float m);
(18)
 double sample_stdev(const double *first, const double *last, double m);
(19)
template <typename Range> typename Range::value_type sample_stdev(const Range& data);
(20)
template <typename Range> typename Range::value_type sample_stdev(const Range& data, float m);
(21)
template <typename Range> typename Range::value_type sample_stdev(const Range& data, double m);
(22)
 float sample_standard_deviation(const float *first, size_t nbelem);
(23)
 double sample_standard_deviation(const double *first, size_t nbelem);
(24)
 float sample_standard_deviation(const float *first, size_t nbelem, float m);
(25)
 double sample_standard_deviation(const double *first, size_t nbelem, double m);
(26)
 float sample_standard_deviation(const float *first, const float *last);
(27)
 double sample_standard_deviation(const double *first, const double *last);
(28)
 float sample_standard_deviation(const float *first, const float *last, float m);
(29)
 double sample_standard_deviation(const double *first, const double *last, double m);
(30)
template <typename Range> typename Range::value_type sample_standard_deviation(const Range& data);
(31)
template <typename Range> typename Range::value_type sample_standard_deviation(const Range& data, float m);
(32)
template <typename Range> typename Range::value_type sample_standard_deviation(const Range& data, double m);
(33)
subroutine archr_stats_sample_stdevp_f32(real(4) :: r, real(4), dimension(*), parameter :: first, integer(4) :: nbelem)
(1)
subroutine archr_stats_sample_stdevp_f64(real(8) :: r, real(8), dimension(*), parameter :: first, integer(4) :: nbelem)
(2)
subroutine archr_stats_sample_stdevp2_f32(real(4) :: r, real(4), dimension(*), parameter :: first, integer(4) :: nbelem, real(4) :: m)
(3)
subroutine archr_stats_sample_stdevp2_f64(real(8) :: r, real(8), dimension(*), parameter :: first, integer(4) :: nbelem, real(8) :: m)
(4)
subroutine archr_stats_sample_standard_deviation_f32(real(4) :: r, real(4), dimension(*), parameter :: first, integer(4) :: nbelem)
(5)
subroutine archr_stats_sample_standard_deviation_f64(real(8) :: r, real(8), dimension(*), parameter :: first, integer(4) :: nbelem)
(6)
subroutine archr_stats_sample_standard_deviation2_f32(real(4) :: r, real(4), dimension(*), parameter :: first, integer(4) :: nbelem, real(4) :: m)
(7)
subroutine archr_stats_sample_standard_deviation2_f64(real(8) :: r, real(8), dimension(*), parameter :: first, integer(4) :: nbelem, real(8) :: m)
(8)
subroutine archr_stats_sample_stdev_f32(real(4) :: r, real(4), dimension(*), parameter :: first, integer(4) :: nbelem)
(9)
subroutine archr_stats_sample_stdev_f64(real(8) :: r, real(8), dimension(*), parameter :: first, integer(4) :: nbelem)
(10)
subroutine archr_stats_sample_stdev2_f32(real(4) :: r, real(4), dimension(*), parameter :: first, integer(4) :: nbelem, real(4) :: m)
(11)
subroutine archr_stats_sample_stdev2_f64(real(8) :: r, real(8), dimension(*), parameter :: first, integer(4) :: nbelem, real(8) :: m)
(12)
def sample_stdevp(first):
    return r
(1)
def sample_stdevp(first, m):
    return r
(2)
def sample_stdev(first):
    return r
(3)
def sample_stdev(first, m):
    return r
(4)
def sample_standard_deviation(first):
    return r
(5)
def sample_standard_deviation(first, m):
    return r
(6)
function r = archr_stats_sample_stdev(first)
(1)
function r = archr_stats_sample_stdev(first, m)
(2)
function r = archr_stats_sample_stdevp(first)
(3)
function r = archr_stats_sample_stdevp(first, m)
(4)
function r = archr_stats_sample_standard_deviation(first)
(5)
function r = archr_stats_sample_standard_deviation(first, m)
(6)

Description

This function computes the bias-corrected standard deviation based on the bias-corrected variance of the elements stored in:

Note that the stdev_* function variants are provided as a convenience alias for migration from spreadsheet or Matlab like code.

Parameters

first

the beginning of the range of elements to process.

last

the end of the range of elements to process.

m

the mean of the range of elements.

nbelem

the number of elements to process.

Return value

The standard deviation of the elements in the given range using the following formula:

$$\sigma(X,n) = \sqrt{V(X,n)}$$

with \(V(X,n)\) being the bias-corrected variance of the given range.

If m is not provided, the mean of the elements range is computed beforehand.

Example

#include <archr/stats/sample_standard_deviation.h>
#include <stdio.h>

int main()
{
  float v[] = {1,-2,3,-4,5,-6};

  printf("sample_standard_deviation(1,-2,3,-4,5,-6) = %f\n", archr_stats_sample_standard_deviation_f32(&v[0],6) );

  puts("");

  printf("sample_standard_deviation(1,-2,3,-4,5,-6) with m = -0.5 = %f\n", archr_stats_sample_standard_deviation2_f32(&v[0], 6, -0.5));

  return 0;
}

Possible Output

sample_standard_deviation(1,-2,3,-4,5,-6) = 4.230839
sample_standard_deviation(1,-2,3)      = 2.516612

sample_standard_deviation(1,-2,3,-4,5,-6) with m = -0.5 = 4.230839
sample_standard_deviation(1,-2,3)         with m =  2/3 = 2.516612
#include <archr/stats/sample_standard_deviation.hpp>
#include <iostream>
#include <vector>

int main()
{
  std::vector<float> v{1,-2,3,-4,5,-6};

  std::cout << "sample_standard_deviation(1,-2,3,-4,5,-6) = " << archr::stats::sample_standard_deviation(v) << "\n";
  std::cout << "sample_standard_deviation(1,-2,3,-4,5)    = " << archr::stats::sample_standard_deviation(v.data(), 5) << "\n";
  std::cout << "sample_standard_deviation(1,-2,3)         = " << archr::stats::sample_standard_deviation(v.data(), v.data() + 3) << "\n";
  std::cout << "\n";

  std::cout << "sample_standard_deviation(1,-2,3,-4,5,-6) with m = -0.5 = " << archr::stats::sample_standard_deviation(v,-0.5) << "\n";
  std::cout << "sample_standard_deviation(1,-2,3,-4,5)    with m =  0.6 = " << archr::stats::sample_standard_deviation(v.data(), 5, 0.6) << "\n";
  std::cout << "sample_standard_deviation(1,-2,3)         with m =  2/3 = " << archr::stats::sample_standard_deviation(v.data(), v.data() + 3, 2./3) << "\n";

  return 0;
}

Possible Output

sample_standard_deviation(1,-2,3,-4,5,-6) = 4.23084
sample_standard_deviation(1,-2,3,-4,5)    = 3.64692
sample_standard_deviation(1,-2,3)         = 2.51661

sample_standard_deviation(1,-2,3,-4,5,-6) with m = -0.5 = 4.23084
sample_standard_deviation(1,-2,3,-4,5)    with m =  0.6 = 3.64692
sample_standard_deviation(1,-2,3)         with m =  2/3 = 2.51661

Possible Output