1#ifndef TTTRLIB_DECAYSTATISTICS_H
2#define TTTRLIB_DECAYSTATISTICS_H
35double wcm(
int C,
double m);
55double wcm_p2s(
int C,
double mp,
double ms);
66double Wcm_p2s(
int* C,
double* M,
int Nchannels);
111double Wcm(
int* C,
double* M,
int Nchannels);
116 inline double neyman(
double* data,
double *model,
int start,
int stop){
118 for(
int i = start; i < stop; i++){
119 double mu = model[i];
120 double m = std::max(1., data[i]);
121 chi2 += (mu - m) * (mu - m) / m;
126 inline double poisson(
double* data,
double *model,
int start,
int stop){
128 for(
int i = start; i < stop; i++){
129 double mu = model[i];
131 chi2 += 2 * std::abs(mu);
132 chi2 -= 2 * m * (1 + log(std::max(1.0, mu) / std::max(1.0, m)));
137 inline double pearson(
double* data,
double *model,
int start,
int stop){
139 for(
int i = start; i < stop; i++){
149 inline double gauss(
double* data,
double *model,
int start,
int stop){
151 for(
int i = start; i < stop; i++){
152 double mu = model[i];
154 double mu_p = std::sqrt(.25 + m * m) - 0.5;
155 if(mu_p <= 1.e-12)
continue;
156 chi2 += (mu - m) * (mu - m) / mu + std::log(mu/mu_p) - (mu_p - m) * (mu_p - m) / mu_p;
161 inline double cnp(
double* data,
double *model,
int start,
int stop){
163 for(
int i = start; i < stop; i++){
165 double mu = model[i];
166 if(m <= 1e-12)
continue;
167 chi2 += (mu - m) * (mu - m) / (3. / (1./m + 2./mu));
173 inline double sswr(
double* data,
double *model,
double *data_noise,
int start,
int stop){
175 for(
int i=start;i<stop;i++){
176 double d = (data[i] - model[i]) / data_noise[i];
196 std::vector<double> &data,
197 std::vector<double> &model,
198 std::vector<double> &weights,
201 const char* type =
"neyman"
double loggammaf(double t)
double Wcm_p2s(int *C, double *M, int Nchannels)
double Wcm(int *C, double *M, int Nchannels)
double wcm_p2s(int C, double mp, double ms)
double twoIstar_p2s(int *C, double *M, int Nchannels)
double wcm(int C, double m)
double twoIstar(int *C, double *M, int Nchannels)
Definition DecayStatistics.h:114
double chi2_counting(std::vector< double > &data, std::vector< double > &model, std::vector< double > &weights, int x_min=-1, int x_max=-1, const char *type="neyman")
Computes different chi2 measures for counting data.
double neyman(double *data, double *model, int start, int stop)
Definition DecayStatistics.h:116
double pearson(double *data, double *model, int start, int stop)
Definition DecayStatistics.h:137
double sswr(double *data, double *model, double *data_noise, int start, int stop)
Sum of squared weighted residuals.
Definition DecayStatistics.h:173
double cnp(double *data, double *model, int start, int stop)
Definition DecayStatistics.h:161
double gauss(double *data, double *model, int start, int stop)
Definition DecayStatistics.h:149
double poisson(double *data, double *model, int start, int stop)
Definition DecayStatistics.h:126