Statistics-CaseResampling
view release on metacpan or search on metacpan
CaseResampling.xs view on Meta::CPAN
/* "confidence" is 1-alpha */
I32 runs, nelem, i_run;
double *csample, *destsample, *medians;
struct mt* rnd;
double median = 0.;
double lower_ci = 0.;
double upper_ci = 0.;
double alpha;
INIT:
alpha = 1.-confidence;
PPCODE:
if (items == 2)
runs = 1000;
else if (items == 3)
runs = SvUV(ST(2));
else {
croak("Usage: ($lower, $median, $upper) = median_confidence_limits(\\@sample, $confidence, [$nruns]);");
}
if (confidence <= 0. || confidence >= 1.) {
croak("Confidence level has to be in (0, 1)");
}
CaseResampling.xs view on Meta::CPAN
double confidence
PREINIT:
/* "confidence" is 1-alpha */
I32 nelem;
double *cstatistics;
double lower_ci = 0.;
double upper_ci = 0.;
double alpha;
INIT:
alpha = 1.-confidence;
PPCODE:
if (confidence <= 0. || confidence >= 1.) {
croak("Confidence level has to be in (0, 1)");
}
avToCAry(aTHX_ statistics, &cstatistics, &nelem);
if (nelem != 0) {
/* lower = t - (t*_((R+1)*(1-alpha)) - t)
* upper = t - (t*_((R+1)*alpha) - t)
*/
lower_ci = 2.*statistic - cs_select( cstatistics, nelem, (I32)((nelem+1.)*(1.-alpha)) );
upper_ci = 2.*statistic - cs_select( cstatistics, nelem, (I32)((nelem+1.)*alpha) );
( run in 1.219 second using v1.01-cache-2.11-cpan-5511b514fd6 )