Back to Documentations

Signature Description Parameters
#include <DataFrame/DataFrameStatsVisitors.h>

template<arithmetic T, typename I = unsigned long>
struct  SkewVisitor;
This functor class calculates the following statisticsthe skew of a population (given column).
Population skewness is a statistical measure of asymmetry in a population's distribution, indicating if data points are concentrated on one side or if the distribution is unbalanced.
T: Column data type.
I: Index type.
#include <DataFrame/DataFrameStatsVisitors.h>

template<arithmetic T, typename I = unsigned long>
struct  KurtosisVisitor;
This functor class calculates the following statisticsthe kurtosis of a population (given column).
Population kurtosis measures the "tailedness" of a distribution compared to a normal distribution, with positive kurtosis indicating heavier tails (leptokurtic) and negative kurtosis indicating lighter tails (platykurtic).
T: Column data type.
I: Index type.
static void test_SkewVisitor()  {

    std::cout << "\nTesting SkewVisitor{ } ..." << std::endl;

    ULDataFrame                 df;
    std::vector<unsigned long>  idxvec = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
    std::vector<double>         dblvec = { 2.2, 4, 5, 15.5, 7, 8, 4.4, 12, 12.6, 11, 6.8, 5.5, 10.1, 9.8, 1.2 };
    std::vector<double>         dblvec2 = { 100, 101, 0, 103, 104, 103.9, 106.55, 106.34, 1.8, 0, 112, 111.5, 114, 1.2, 3.3 };

    df.load_data(std::move(idxvec),
                 std::make_pair("dbl_col", dblvec),
                 std::make_pair("dbl_col_2", dblvec2));

    SkewVisitor<double, unsigned long>  skew;

    df.visit<double>("dbl_col", skew);
    assert(std::fabs(skew.get_result() - 0.2049) < 0.0001);
    df.visit<double>("dbl_col_2", skew);
    assert(std::fabs(skew.get_result() - -0.6896) < 0.0001);
}
// ----------------------------------------------------------------------------

static void test_KurtosisVisitor()  {

    std::cout << "\nTesting KurtosisVisitor{ } ..." << std::endl;

    ULDataFrame                 df;
    std::vector<unsigned long>  idxvec = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
    std::vector<double>         dblvec = { 2.2, 4, 5, 15.5, 7, 8, 4.4, 12, 12.6, 11, 6.8, 5.5, 10.1, 9.8, 1.2 };
    std::vector<double>         dblvec2 = { 100, 101, 0, 103, 104, 103.9, 106.55, 106.34, 1.8, 0, 112, 111.5, 114, 1.2, 3.3 };

    df.load_data(std::move(idxvec),
                 std::make_pair("dbl_col", dblvec),
                 std::make_pair("dbl_col_2", dblvec2));

    KurtosisVisitor<double, unsigned long>  kurt;

    df.visit<double>("dbl_col", kurt);
    assert(std::fabs(kurt.get_result() - -0.8557) < 0.0001);
    df.visit<double>("dbl_col_2", kurt);
    assert(std::fabs(kurt.get_result() - -1.4976) < 0.0001);
}

C++ DataFrame