skewness (Descriptive Statistics)


Import

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

Synopsis

 float archr_stats_skewness_f32(const float *first, size_t nbelem);
(1)
 double archr_stats_skewness_f64(const double *first, size_t nbelem);
(2)
 float archr_stats_skewness2_f32(const float *first, size_t nbelem, float m);
(3)
 double archr_stats_skewness2_f64(const double *first, size_t nbelem, double m);
(4)
 float skewness(const float *first, size_t nbelem);
(1)
 double skewness(const double *first, size_t nbelem);
(2)
 float skewness(const float *first, size_t nbelem, float m);
(3)
 double skewness(const double *first, size_t nbelem, double m);
(4)
 float skewness(const float *first, const float *last);
(5)
 double skewness(const double *first, const double *last);
(6)
 float skewness(const float *first, const float *last, float m);
(7)
 double skewness(const double *first, const double *last, double m);
(8)
template <typename Range> typename Range::value_type skewness(const Range& data);
(9)
template <typename Range> typename Range::value_type skewness(const Range& data, float m);
(10)
template <typename Range> typename Range::value_type skewness(const Range& data, double m);
(11)
subroutine archr_stats_skewness_f32(real(4) :: r, real(4), dimension(*), parameter :: first, integer(4) :: nbelem)
(1)
subroutine archr_stats_skewness_f64(real(8) :: r, real(8), dimension(*), parameter :: first, integer(4) :: nbelem)
(2)
subroutine archr_stats_skewness2_f32(real(4) :: r, real(4), dimension(*), parameter :: first, integer(4) :: nbelem, real(4) :: m)
(3)
subroutine archr_stats_skewness2_f64(real(8) :: r, real(8), dimension(*), parameter :: first, integer(4) :: nbelem, real(8) :: m)
(4)
def skewness(first):
    return r
(1)
def skewness(first, m):
    return r
(2)
function r = archr_stats_skewness(first)
(1)
function r = archr_stats_skewness(first, m)
(2)

Description

This function computes the skewness of the elements stored in:

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 skewness of the elements in the given range using the following formula:

$$\gamma_1=\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/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("skewness(1,1.5f,2,4.5f, ... ,6.f,7.f,8.f) = %f\n", archr_stats_skewness_f32(&v[0],11));
  puts("");

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

  return 0;
}

Possible Output

skewness(1,1.5f,2,4.5f, ... ,6.f,7.f,8.f) = -0.064760
skewness(4.7f,4.4f,4.5f,6.f,7.f,8.f)      = 0.659966

skewness(1,1.5f,2,4.5f, ... ,6.f,7.f,8.f) with m = 4.38182 = -0.064763
skewness(1,1.5f,2,4.5f,4.6f,4.7f,4.4f)    with m = 3.24286 = -0.369850
#include <archr/stats/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 << "skewness(1,1.5f,2,4.5f, ... ,6.f,7.f,8.f) = " << archr::stats::skewness(v) << "\n";
  std::cout << "skewness(1,1.5f,2,4.5f,4.6f,4.7f,4.4f)    = " << archr::stats::skewness(v.data(),7) << "\n";
  std::cout << "skewness(4.7f,4.4f,4.5f,6.f,7.f,8.f)      = " << archr::stats::skewness(v.data()+5,v.data()+10) << "\n";
  std::cout << "\n";

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

  return 0;
}

Possible Output

skewness(1,1.5f,2,4.5f, ... ,6.f,7.f,8.f) = -0.0647601
skewness(1,1.5f,2,4.5f,4.6f,4.7f,4.4f)    = -0.369844
skewness(4.7f,4.4f,4.5f,6.f,7.f,8.f)      = 0.659966

skewness(1,1.5f,2,4.5f, ... ,6.f,7.f,8.f) with m = 4.38182 = -0.0647635
skewness(1,1.5f,2,4.5f,4.6f,4.7f,4.4f)    with m = 3.24286 = -0.36985
skewness(4.7f,4.4f,4.5f,6.f,7.f,8.f)      with m = 5.32 = 0.659966

Possible Output