Skip to content

sam::TTest

Module: Test Strategies

Declration of t-test. More...

#include <TestStrategy.h>

Inherits from sam::TestStrategy

Public Classes

Name
struct Parameters
struct ResultType

Public Functions

Name
TTest(const Parameters & p)
virtual void run(Experiment * experiment) override
virtual void run(DependentVariable & group_1, DependentVariable & group_2) override
ResultType t_test(const arma::Row< float > & d1, const arma::Row< float > & d2, float alpha, TestStrategy::TestAlternative alternative)
ResultType t_test(float Sm1, float Sd1, float Sn1, float Sm2, float Sd2, float Sn2, float alpha, TestStrategy::TestAlternative alternative, bool equal_var)
std::pair< float, bool > compute_pvalue(float tstat, float df, float alpha, TestStrategy::TestAlternative alternative)
ResultType single_sample_t_test(float M, float Sm, float Sd, unsigned Sn, float alpha, TestStrategy::TestAlternative alternative)
ResultType two_samples_t_test_equal_sd(float Sm1, float Sd1, unsigned Sn1, float Sm2, float Sd2, unsigned Sn2, float alpha, TestStrategy::TestAlternative alternative)
ResultType two_samples_t_test_unequal_sd(float Sm1, float Sd1, unsigned Sn1, float Sm2, float Sd2, unsigned Sn2, float alpha, TestStrategy::TestAlternative alternative)

Public Attributes

Name
Parameters params

Additional inherited members

Public Types inherited from sam::TestStrategy

Name
enum TestMethod
enum TestAlternative

Public Functions inherited from sam::TestStrategy

Name
virtual ~TestStrategy() =0
virtual float alpha()
std::unique_ptr< TestStrategy > build(json & test_strategy_config)

Public Attributes inherited from sam::TestStrategy

Name
float alpha_

Detailed Description

class sam::TTest;

Declration of t-test.

The run() method will check the significance of the difference between two groups. In the current setup, every experiment->means is considered an effect size between a treatment group and a control group with the mean of zero. Therefore, computing the t-statistics and computing the p-value would be sufficient. This is technically an implementation of one sample t-test.

Public Functions Documentation

function TTest

inline TTest(
    const Parameters & p
)

function run

virtual void run(
    Experiment * experiment
) override

Reimplements: sam::TestStrategy::run

function run

inline virtual void run(
    DependentVariable & group_1,
    DependentVariable & group_2
) override

Reimplements: sam::TestStrategy::run

function t_test

static ResultType t_test(
    const arma::Row< float > & d1,
    const arma::Row< float > & d2,
    float alpha,
    TestStrategy::TestAlternative alternative
)

function t_test

static ResultType t_test(
    float Sm1,
    float Sd1,
    float Sn1,
    float Sm2,
    float Sd2,
    float Sn2,
    float alpha,
    TestStrategy::TestAlternative alternative,
    bool equal_var
)

function compute_pvalue

static std::pair< float, bool > compute_pvalue(
    float tstat,
    float df,
    float alpha,
    TestStrategy::TestAlternative alternative
)

function single_sample_t_test

static ResultType single_sample_t_test(
    float M,
    float Sm,
    float Sd,
    unsigned Sn,
    float alpha,
    TestStrategy::TestAlternative alternative
)

Parameters:

  • M True Mean.
  • Sm Sample Mean.
  • Sd Sample Standard Deviation.
  • Sn Sample Size.
  • alpha Significance Level.

Return: TTest::ResultType

Note: Obtained from Boost Library Example.

A Students t test applied to a single set of data. We are testing the null hypothesis that the true mean of the sample is M, and that any variation is down to chance. We can also test the alternative hypothesis that any difference is not down to chance

function two_samples_t_test_equal_sd

static ResultType two_samples_t_test_equal_sd(
    float Sm1,
    float Sd1,
    unsigned Sn1,
    float Sm2,
    float Sd2,
    unsigned Sn2,
    float alpha,
    TestStrategy::TestAlternative alternative
)

Parameters:

  • Sm1 Sample Mean 1.
  • Sd1 Sample Standard Deviation 1.
  • Sn1 Sample Size 1.
  • Sm2 Sample Mean 2.
  • Sd2 Sample Standard Deviation 2.
  • Sn2 Sample Size 2.
  • alpha Significance Level.

Return: TTest::ResultType

Note: Obtained from Boost Library Example.

A Students t test applied to two sets of data. We are testing the null hypothesis that the two samples have the same mean and that any difference if due to chance.

function two_samples_t_test_unequal_sd

static ResultType two_samples_t_test_unequal_sd(
    float Sm1,
    float Sd1,
    unsigned Sn1,
    float Sm2,
    float Sd2,
    unsigned Sn2,
    float alpha,
    TestStrategy::TestAlternative alternative
)

Parameters:

  • Sm1 Sample Mean 1.
  • Sd1 Sample Standard Deviation 1.
  • Sn1 Sample Size 1.
  • Sm2 Sample Mean 2.
  • Sd2 Sample Standard Deviation 2.
  • Sn2 Sample Size 2.
  • alpha Significance Level.

Return: TTest::ResultType

Note: Obtained from Boost Library Example.

A Students t test applied to two sets of data with unequal variance. We are testing the null hypothesis that the two samples have the same mean and that any difference is due to chance.

Public Attributes Documentation

variable params

Parameters params;

Updated on 29 June 2021 at 16:13:48 CEST


Last update: 2021-09-18