skewness (sampled) (Descriptive Statistics)


Import

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

Synopsis

 float archr_stats_sample_skewness_f32(const float *first, size_t nbelem);
(1)
 double archr_stats_sample_skewness_f64(const double *first, size_t nbelem);
(2)
 float archr_stats_sample_skewness2_f32(const float *first, size_t nbelem, float m);
(3)
 double archr_stats_sample_skewness2_f64(const double *first, size_t nbelem, double m);
(4)
 float sample_skewness(const float *first, size_t nbelem);
(1)
 double sample_skewness(const double *first, size_t nbelem);
(2)
 float sample_skewness(const float *first, size_t nbelem, float m);
(3)
 double sample_skewness(const double *first, size_t nbelem, double m);
(4)
 float sample_skewness(const float *first, const float *last);
(5)
 double sample_skewness(const double *first, const double *last);
(6)
 float sample_skewness(const float *first, const float *last, float m);
(7)
 double sample_skewness(const double *first, const double *last, double m);
(8)
template <typename Range> typename Range::value_type sample_skewness(const Range& data);
(9)
template <typename Range> typename Range::value_type sample_skewness(const Range& data, float m);
(10)
template <typename Range> typename Range::value_type sample_skewness(const Range& data, double m);
(11)
subroutine archr_stats_sample_skewness_f32(real(4) :: r, real(4), dimension(*), parameter :: first, integer(4) :: nbelem)
(1)
subroutine archr_stats_sample_skewness_f64(real(8) :: r, real(8), dimension(*), parameter :: first, integer(4) :: nbelem)
(2)
subroutine archr_stats_sample_skewness2_f32(real(4) :: r, real(4), dimension(*), parameter :: first, integer(4) :: nbelem, real(4) :: m)
(3)
subroutine archr_stats_sample_skewness2_f64(real(8) :: r, real(8), dimension(*), parameter :: first, integer(4) :: nbelem, real(8) :: m)
(4)
def sample_skewness(first):
    return r
(1)
def sample_skewness(first, m):
    return r
(2)
function r = archr_stats_sample_skewness(first)
(1)
function r = archr_stats_sample_skewness(first, m)
(2)

Description

This function computes the bias-corrected skewness of the elements stored in:

Note that the skew functions 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.

nbelem

the number of elements to process.

m

the mean of the range of elements.

Return value

The bias-corrected skewness of the elements in the given range or container using the following formula:

$$\gamma_1(n)=\sqrt{\frac{n*(n-1)}{n-2}}\mu_3/\sqrt{\mu_2^3}$$

where \(\mu_i\) is the \(i^{th}\)$$ central moment. If m is not provided, the mean of the elements range is computed beforehand.

Example

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

int main()
{
  float v[] = {1,1.5f,2,4.5f,4.6f,4.7f,4.4f,4.5f,6.f,7.f,8.f};

  printf("sample_skewness(1,1.5f,2,4.5f, ... ,6.f,7.f,8.f) = %f\n", archr_stats_sample_skewness_f32(&v[0],11));
  puts("");

  printf("sample_skewness(1,1.5f,2,4.5f, ... ,6.f,7.f,8.f) with m = 4.38182 = %f\n", archr_stats_sample_skewness2_f32(&v[0],11,4.38182));

  return 0;
}

Possible Output

sample_skewness(1,1.5f,2,4.5f, ... ,6.f,7.f,8.f) = -0.075468
sample_skewness(4.7f,4.4f,4.5f,6.f,7.f,8.f)      = 0.983819

sample_skewness(1,1.5f,2,4.5f, ... ,6.f,7.f,8.f) with m = 4.38182 = -0.075472
sample_skewness(1,1.5f,2,4.5f,4.6f,4.7f,4.4f)    with m = 3.24286 = -0.479380
#include <archr/stats/sample_skewness.hpp>
#include <iostream>
#include <vector>

int main()
{
  std::vector<float> v{1,1.5f,2,4.5f,4.6f,4.7f,4.4f,4.5f,6.f,7.f,8.f};

  std::cout << "sample_skewness(1,1.5f,2,4.5f, ... ,6.f,7.f,8.f) = " << archr::stats::sample_skewness(v) << "\n";
  std::cout << "sample_skewness(1,1.5f,2,4.5f,4.6f,4.7f,4.4f)    = " << archr::stats::sample_skewness(v.data(),7) << "\n";
  std::cout << "sample_skewness(4.7f,4.4f,4.5f,6.f,7.f,8.f)      = " << archr::stats::sample_skewness(v.data()+5,v.data()+10) << "\n";
  std::cout << "\n";

  std::cout << "sample_skewness(1,1.5f,2,4.5f, ... ,6.f,7.f,8.f) with m = 4.38182 = " << archr::stats::sample_skewness(v,4.38182) << "\n";
  std::cout << "sample_skewness(1,1.5f,2,4.5f,4.6f,4.7f,4.4f)    with m = 3.24286 = " << archr::stats::sample_skewness(v.data(),7,3.24286f) << "\n";
  std::cout << "sample_skewness(4.7f,4.4f,4.5f,6.f,7.f,8.f)      with m = 5.32 = " << archr::stats::sample_skewness(v.data()+5,v.data()+10,5.32) << "\n";

  return 0;
}

Possible Output

sample_skewness(1,1.5f,2,4.5f, ... ,6.f,7.f,8.f) = -0.0754678
sample_skewness(1,1.5f,2,4.5f,4.6f,4.7f,4.4f)    = -0.479372
sample_skewness(4.7f,4.4f,4.5f,6.f,7.f,8.f)      = 0.983819

sample_skewness(1,1.5f,2,4.5f, ... ,6.f,7.f,8.f) with m = 4.38182 = -0.0754717
sample_skewness(1,1.5f,2,4.5f,4.6f,4.7f,4.4f)    with m = 3.24286 = -0.47938
sample_skewness(4.7f,4.4f,4.5f,6.f,7.f,8.f)      with m = 5.32 = 0.983819

Possible Output