24#include <gsl/gsl_randist.h>
25#include <gsl/gsl_cdf.h>
26#include <gsl/gsl_statistics_double.h>
28#include <lal/LALStdlib.h>
29#include <lal/LALConstants.h>
30#include <lal/VectorOps.h>
43 return gsl_ran_exponential( ptrToGenerator,
mu );
51 for (
UINT4 ii = 0; ii < length; ii++ ) {
83 REAL4 vector_median = 0.0;
84 if ( tempvect->
length % 2 != 1 ) {
87 vector_median = tempvect->
data[(
INT4 )( 0.5 * tempvect->
length )];
95 for ( ii = 0; ii < (
INT4 )tempvect->
length; ii++ ) {
96 REAL8 pval = gsl_cdf_exponential_P( tempvect->
data[ii], vector_mean );
97 testval1 = fabs( ( 1.0 + ii ) * oneoverlength - pval );
98 testval2 = fabs( ii * oneoverlength - pval );
100 if (
testval > ( *ksvalue ) ) {
140 REAL4 vector_median = 0.0;
141 if ( tempvect->
length % 2 != 1 ) {
144 vector_median = tempvect->
data[(
INT4 )( 0.5 * tempvect->
length )];
150 REAL8 loval = 0.0, hival = 0.0;
152 loval = -1.0, hival = -1.0;
153 for ( ii = 0; ii < (
INT4 )tempvect->
length; ii++ ) {
154 REAL8 pval = gsl_cdf_exponential_P( tempvect->
data[ii], vector_mean );
155 REAL8 testval1 = ( 1.0 + ii ) * oneoverlength - pval;
156 REAL8 testval2 = ii * oneoverlength - pval;
157 if ( hival < testval1 ) {
160 if ( hival < testval2 ) {
163 if ( loval < -testval1 ) {
166 if ( loval < -testval2 ) {
170 *kuipervalue = hival + loval;
256 for (
UINT4 ii = 0; ii < sampleSize; ii++ ) {
258 while (
output->data[ii] == 0.0 ) {
278 meanval += (
vector->data[ii] - meanval ) / ( ii + 1 );
281 return (
REAL4 )meanval;
297 if (
vector->data[ii] != 0.0 ) {
298 meanval +=
vector->data[ii];
304 return (
REAL4 )( meanval / values );
329 for (
UINT4 ii = 0; ii < numffts; ii++ ) {
330 if (
vector->data[ii * numfbins] != 0.0 ) {
331 memcpy( tempvect->
data, &(
vector->data[ii * numfbins] ),
sizeof(
REAL4 )*numfbins );
332 *harmonicMean += 1.0 /
calcMean( tempvect );
337 *harmonicMean = (
REAL4 )values / ( *harmonicMean );
358 double *gslarray = NULL;
361 gslarray[ii] = ( double )
vector->data[ii];
363 *sigma = (
REAL4 )gsl_stats_sd( gslarray, 1,
vector->length );
382 if ( meanval == 0.0 ) {
388 REAL8 sumtotal = 0.0;
390 if (
vector->data[ii] != 0.0 ) {
391 sumtotal += (
vector->data[ii] - meanval ) * (
vector->data[ii] - meanval );
397 *sigma = sqrtf( (
REAL4 )( sumtotal / ( values - 1 ) ) );
399 }
else if ( values == 1 ) {
420 *rms = sqrtf(
calcMean( sqvector ) );
465 if (
vector->data[ii] > maxval ) {
466 maxval =
vector->data[ii];
501 UINT4 indexval = startlocation;
504 for (
UINT4 ii = startlocation + 1; ii <=
last; ii++ ) {
505 if (
vector->data[ii] > maxval ) {
506 maxval =
vector->data[ii];
525 *min_index_out = 0, *max_index_out = 0;
530 if ( inputvector->
data[ii] < minval ) {
531 minval = inputvector->
data[ii];
534 if ( inputvector->
data[ii] > maxval ) {
535 maxval = inputvector->
data[ii];
561 if ( tempvect->
length % 2 != 1 ) {
INT4 calcHarmonicMean(REAL4 *harmonicMean, const REAL4VectorAligned *vector, const UINT4 numfbins, const UINT4 numffts)
Compute the harmonic mean value of a REAL4VectorAligned of SFT values.
void sort_float_ascend(REAL4VectorAligned *vector)
Sort a REAL4VectorAligned in ascending order, modifying the input vector.
INT4 calcMedian(REAL4 *median, const REAL4VectorAligned *vector)
Calculate the median value from a REAL4VectorAligned.
INT4 sort_float_smallest(REAL4VectorAligned *output, const REAL4VectorAligned *input)
Sort a REAL4VectorAligned, keeping the smallest of the values in the output vector.
REAL4 calcMean_ignoreZeros(const REAL4VectorAligned *vector)
Compute the mean value of a REAL4VectorAligned without accepting values of zero.
INT4 qsort_REAL4_compar(const void *a, const void *b)
INT4 qsort_REAL8_compar(const void *a, const void *b)
INT4 min_max_index_INT4Vector(const INT4Vector *inputvector, UINT4 *min_index_out, UINT4 *max_index_out)
Determine the index value of the maximum and minimum values in an INT4Vector.
INT4 sampleREAL4VectorAligned(REAL4VectorAligned *output, const REAL4VectorAligned *input, const gsl_rng *rng)
Sample a number (sampleSize) of values from a REAL4VectorAligned (input) randomly.
UINT4 max_index_double(const REAL8Vector *vector)
Determine the index value of the maximum value in a REAL8Vector.
INT4 kuipers_test_exp(REAL8 *kuipervalue, const REAL4VectorAligned *vector)
Kuiper's test of data against an expected exponential distribution.
INT4 calcRms(REAL4 *rms, const REAL4VectorAligned *vector)
Compute the RMS value of a REAL4VectorAligned.
INT4 calcStddev_ignoreZeros(REAL4 *sigma, const REAL4VectorAligned *vector)
Compute the standard deviation of a REAL4VectorAligned ignoring zero values.
INT4 ks_test_exp(REAL8 *ksvalue, const REAL4VectorAligned *vector)
KS test of data against an expected exponential distribution.
REAL8 calcStddevD(const REAL8Vector *vector)
Compute the standard deviation of a REAL8Vector.
REAL8 expRandNum(const REAL8 mu, const gsl_rng *ptrToGenerator)
Create a exponentially distributed noise value.
UINT4 max_index(const REAL4VectorAligned *vector)
Determine the index value of the maximum value in a REAL4VectorAligned.
void sort_double_ascend(REAL8Vector *vector)
Sort a REAL8Vector in ascending order, modifying the input vector.
INT4 calcStddev(REAL4 *sigma, const REAL4VectorAligned *vector)
Compute the standard deviation of a REAL4VectorAligned.
REAL4VectorAligned * expRandNumVector(const UINT4 length, const REAL8 mu, const gsl_rng *ptrToGenerator)
UINT4 max_index_in_range(const REAL4VectorAligned *vector, const UINT4 startlocation, const UINT4 lastlocation)
Determine the index value of the maximum value between elements of a REAL4VectorAligned (inclusive)
REAL4 calcMean(const REAL4VectorAligned *vector)
Compute the mean value of a REAL4VectorAligned, computed via recursion like in GSL.
REAL4VectorAligned * sampleREAL4VectorAlignedArray_nozerosaccepted(const REAL4VectorAlignedArray *input, const UINT4 numberofvectors, const UINT4 sampleSize, const gsl_rng *rng)
Sample a number (sampleSize) of values from an REAL4VectorAlignedArray (input) randomly from vector 0...
REAL8 calcMeanD(const REAL8Vector *vector)
Compute the mean value of a REAL8Vector.
void * XLALMalloc(size_t n)
void XLALDestroyREAL4VectorAligned(REAL4VectorAligned *in)
REAL4VectorAligned * XLALCreateREAL4VectorAligned(const UINT4 length, const UINT4 align)
int XLALVectorMultiplyREAL4(REAL4 *out, const REAL4 *in1, const REAL4 *in2, const UINT4 len)
#define XLAL_CHECK(assertion,...)
#define XLAL_CHECK_REAL8(assertion,...)
#define XLAL_CHECK_NULL(assertion,...)
REAL4VectorAligned ** data