1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2025-11-05 08:29:32 +00:00

2 Commits

Author SHA1 Message Date
e4861e7b50 Hotelling T2 p-value 2025-06-19 22:24:50 +01:00
ee60d083c8 2D grid plot 2025-06-19 22:22:53 +01:00
4 changed files with 52 additions and 0 deletions

View File

@@ -166,5 +166,17 @@ auto chi2CcdfVecFunc = [](const double arg[2])
return gsl_cdf_chisq_Q(arg[0], arg[1]);
};
auto hotellingT2PValueVecFunc = [](const double arg[3])
{
double T2 = arg[0];
double n = arg[1];
double p = arg[2];
double F = (n - p) / (p * (n - 1)) * T2;
double p_value = 1.0 - gsl_cdf_fdist_P(F, p, n - p);
return p_value;
};
DoubleFunction MATH_NAMESPACE::chi2PValue(chi2PValueVecFunc, 2);
DoubleFunction MATH_NAMESPACE::chi2Ccdf(chi2CcdfVecFunc, 2);
DoubleFunction MATH_NAMESPACE::hotellingT2PValue(hotellingT2PValueVecFunc, 3);

View File

@@ -160,6 +160,7 @@ namespace MATH_NAMESPACE
{
extern DoubleFunction chi2PValue;
extern DoubleFunction chi2Ccdf;
extern DoubleFunction hotellingT2PValue;
}
END_LATAN_NAMESPACE

View File

@@ -511,6 +511,36 @@ PlotImpulses::PlotImpulses(const DVec &x, const DVec &y)
setCommand("'" + tmpFileName + "' u 1:2 w impulses");
}
// PlotGrid constructor ////////////////////////////////////////////////////////
PlotGrid::PlotGrid(const DVec &x, const DVec &y, const DMat &value)
{
if (x.size() != value.rows())
{
LATAN_ERROR(Size, "x vector does not have the same size as value matrix rows");
}
if (y.size() != value.cols())
{
LATAN_ERROR(Size, "y vector does not have the same size as value matrix columns");
}
if (value.rows() < 2 || value.cols() < 2)
{
LATAN_ERROR(Size, "value matrix must have at least 2 rows and 2 columns");
}
DMat d(value.cols()+1, value.rows()+1);
string tmpFileName;
d(0,0) = value.cols();
d.row(0).tail(value.cols()) = x;
d.col(0).tail(value.rows()) = y;
for (Index i = 0; i < value.rows(); ++i)
for (Index j = 0; j < value.cols(); ++j)
{
d(i+1, j+1) = value(j, i);
}
tmpFileName = dumpToTmpFile(d);
pushTmpFile(tmpFileName);
setCommand("'" + tmpFileName + "' nonuniform matrix w image");
}
// PlotMatrixNoRange constructor ///////////////////////////////////////////////
PlotMatrixNoRange::PlotMatrixNoRange(const DMat &m)
{

View File

@@ -200,6 +200,15 @@ public:
virtual ~PlotImpulses(void) = default;
};
class PlotGrid: public PlotObject
{
public:
// constructor
PlotGrid(const DVec &x, const DVec &y, const DMat &value);
// destructor
virtual ~PlotGrid(void) = default;
};
class PlotMatrixNoRange: public PlotObject
{
public: