Skip to content

Commit e4861e7

Browse files
committed
Hotelling T2 p-value
1 parent ee60d08 commit e4861e7

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/LatAnalyze/Core/Math.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,5 +166,17 @@ auto chi2CcdfVecFunc = [](const double arg[2])
166166
return gsl_cdf_chisq_Q(arg[0], arg[1]);
167167
};
168168

169+
auto hotellingT2PValueVecFunc = [](const double arg[3])
170+
{
171+
double T2 = arg[0];
172+
double n = arg[1];
173+
double p = arg[2];
174+
double F = (n - p) / (p * (n - 1)) * T2;
175+
double p_value = 1.0 - gsl_cdf_fdist_P(F, p, n - p);
176+
177+
return p_value;
178+
};
179+
169180
DoubleFunction MATH_NAMESPACE::chi2PValue(chi2PValueVecFunc, 2);
170181
DoubleFunction MATH_NAMESPACE::chi2Ccdf(chi2CcdfVecFunc, 2);
182+
DoubleFunction MATH_NAMESPACE::hotellingT2PValue(hotellingT2PValueVecFunc, 3);

lib/LatAnalyze/Core/Math.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ namespace MATH_NAMESPACE
160160
{
161161
extern DoubleFunction chi2PValue;
162162
extern DoubleFunction chi2Ccdf;
163+
extern DoubleFunction hotellingT2PValue;
163164
}
164165

165166
END_LATAN_NAMESPACE

0 commit comments

Comments
 (0)