35 typedef BetaInc<Double> BetaInc;
67 int ci = 100*(1-val.
alpha);
70 <<
"Mean CI " << std::setw(2) << ci
72 <<
"Std Dev CI " << std::setw(2) << ci
74 <<
"DF: " << val.
df <<
endl
75 <<
"t Value: " << val.
t <<
endl
76 << (val.
tail == 0 ?
"Pr > |t|: " :
77 val.
tail == 1 ?
"Pr > t: " :
100 assert(tail >= -1 && tail <= 1);
106 if (tail == 0) p *= 2;
112 stats->meanCi =
Vec2( tail == -1 ? -Real_::inf : d.
mean - meanCi,
113 tail == 1 ? Real_::inf : d.
mean + meanCi);
114 stats->stdDevCi = ChiSqr(df).stdDevCi(d.
stdDev, alpha).template cast<Vec2>();
116 stats->alpha = alpha;
141 int ci = 100*(1-val.
alpha);
145 <<
"Pooled Diff (1 - 2):" <<
endl
150 <<
"Mean CI " << std::setw(2) << ci
152 <<
"Std Dev CI " << std::setw(2) << ci
154 <<
"DF: " << val.
df <<
endl
155 <<
"t Value: " << val.
t <<
endl
156 << (val.
tail == 0 ?
"Pr > |t|: " :
157 val.
tail == 1 ?
"Pr > t: " :
181 template<
class Range,
class Range2>
182 static typename std::enable_if<mt::isRange<Range2>::value,
bool>::type
185 assert(tail >= -1 && tail <= 1);
189 sdt df = d1.
n + d2.
n - 2;
194 Real t = (mean - mu) / stdErr;
196 if (tail == 0) p *= 2;
204 stats->stdErr = stdErr;
205 Real meanCi = student.
cdfInv(1 - (tail == 0 ? alpha/2 : alpha)) * stdErr;
206 stats->meanCi =
Vec2( tail == -1 ? -Real_::inf : mean - meanCi,
207 tail == 1 ? Real_::inf : mean + meanCi);
208 stats->stdDevCi = ChiSqr(df).stdDevCi(stdDev, alpha).template cast<Vec2>();
210 stats->alpha = alpha;
Real t
T-test statistic.
Definition: StudentT.h:62
int tail
Whether test is two-tailed or lower/upper tailed.
Definition: StudentT.h:61
Generate a random variate from a beta distribution .
Definition: Beta.h:30
virtual Real cdfInv(Real P) const
Inverse of the CDF.
Definition: StudentT.cpp:60
friend ostream & operator<<(ostream &os, const PooledStats &val)
Definition: StudentT.h:139
Real t
T-test statistic.
Definition: StudentT.h:136
virtual Real mean() const
Calc mean.
Definition: StudentT.h:51
Vec2 meanCi
Lower and upper 100*(1-alpha)% confidence interval of the pooled mean.
Definition: StudentT.h:131
Real alpha
Test significance level.
Definition: StudentT.h:60
int tail
Whether test is two-tailed or lower/upper tailed.
Definition: StudentT.h:135
Vec< 2, Real > Vec2
Definition: StudentT.h:41
static optnull_t optnull
Null optional, use to reset an optional to an uninitialized state or test for initialization.
Definition: Optional.h:12
Real mean
Pooled mean (1 - 2)
Definition: StudentT.h:128
Real p
Probability of observing value more extreme than t.
Definition: StudentT.h:63
ptrdiff_t sdt
Size difference type, shorthand for ptrdiff_t.
Definition: Core.h:92
Real stdErr
Pooled standard error.
Definition: StudentT.h:130
Generate a random variate from a noncentral chi-square distribution.
Definition: ChiSqr.h:52
friend ostream & operator<<(ostream &os, const Stats &val)
Definition: StudentT.h:65
static Real sqrt(Real x)
Square Root.
Definition: Alge.h:63
StudentT_< Double > StudentT_d
Definition: StudentT.h:224
DistStats dist[2]
Sample distribution stats.
Definition: StudentT.h:127
StudentT_(Real n)
Definition: StudentT.h:44
Vec2 stdDevCi
Lower and upper 100*(1-alpha)% confidence interval of the standard deviation.
Definition: StudentT.h:58
DistStats dist
Sample distribution stats.
Definition: StudentT.h:56
Generate a random variate from a Student's t-distribution.
Definition: StudentT.h:29
virtual Real cdf(Real x) const
Cumulative Distribution Function.
Definition: StudentT.cpp:28
virtual Real variance() const
Calc variance.
Definition: StudentT.h:52
static Int abs(Int x)
Get absolute value of signed integer.
Definition: Alge.h:21
StudentT_< Real > StudentT
Definition: StudentT.h:222
static bool test(const Range &samples, optional< Stats & > stats=optnull, Real mu=0, Real alpha=0.05, int tail=0)
One-sample t-test: Test the null hypothesis that the samples are from a normally distributed populati...
Definition: StudentT.h:98
Real stdDev
Sample standard deviation.
Definition: Random.h:134
szt df
Degrees of freedom.
Definition: StudentT.h:133
ostream & indentInc(ostream &os)
Increase stream indent level by 1.
Definition: Stream.h:32
#define assert(...)
Forwards to assert_#args. See assert_1(), assert_2().
Definition: Debug.h:24
StudentT_< Float > StudentT_f
Definition: StudentT.h:223
ostream & indentDec(ostream &os)
Decrease stream indent level by 1.
Definition: Stream.h:34
szt df
Degrees of freedom.
Definition: StudentT.h:59
szt n
Sample size.
Definition: Random.h:130
float Real
Real number type. See Real_ for real number operations and constants.
Definition: Real.h:21
size_t szt
Size type, shorthand for size_t.
Definition: Core.h:90
Enables any type to be optional so it can exist in an uninitialized null state.
Definition: Optional.h:52
Real stdErr
Standard error of the mean (ie. standard deviation of the sample-mean estimate of the population mean...
Definition: Random.h:135
static DistStats stats(const Range &samples)
Calculate distribution statistics.
Definition: Random.h:152
static Num sqr(Num x)
Square.
Definition: Alge.h:60
Real stdDev
Pooled standard deviation.
Definition: StudentT.h:129
Real n
Definition: StudentT.h:219
Real mean
Sample mean.
Definition: Random.h:131
Random-related methods.
Definition: Random.h:21
virtual Real next() const
Get next randomly distributed variate. Requires a random generator (see ctor or setGen()) ...
Definition: StudentT.cpp:10
virtual Real pdf(Real x) const
Probability Density Function.
Definition: StudentT.cpp:16
Real p
Probability of observing value more extreme than t.
Definition: StudentT.h:137
Real alpha
Test significance level.
Definition: StudentT.h:134
Real stdDev() const
Calc standard deviation.
Definition: Dist.h:81
Vec2 stdDevCi
Lower and upper 100*(1-alpha)% confidence interval of the pooled standard deviation.
Definition: StudentT.h:132
Vec2 meanCi
Lower and upper 100*(1-alpha)% confidence interval of the mean.
Definition: StudentT.h:57
Generate a normally (Gaussian) distributed random variate.
Definition: Gaussian.h:26
Definition: StudentT.h:125
static std::enable_if< mt::isRange< Range2 >::value, bool >::type test(const Range &samples1, const Range2 &samples2, optional< PooledStats & > stats=optnull, Real mu=0, Real alpha=0.05, int tail=0)
Two-sample t-test: Test the null hypothesis that the difference between two sample distributions is a...
Definition: StudentT.h:183
ostream & endl(ostream &os)
End line and apply any indentation to the next line.
Definition: Stream.h:40
Global Honeycomb namespace.
virtual Real cdfComp(Real x) const
Complement of the CDF.
Definition: StudentT.cpp:54
Random::DistStats DistStats
Definition: StudentT.h:40
StudentT_(optional< RandomGen & > gen, Real n)
Definition: StudentT.h:43
Definition: StudentT.h:54
Base class for all random distributions.
Definition: Dist.h:15