| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#ifndef eslHISTOGRAM_INCLUDED |
| 6 |
#define eslHISTOGRAM_INCLUDED |
| 7 |
#include <esl_config.h> |
| 8 |
|
| 9 |
#include <math.h> |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
typedef struct { |
| 26 |
|
| 27 |
|
| 28 |
uint64_t *obs; |
| 29 |
int nb; |
| 30 |
double w; |
| 31 |
double bmin, bmax; |
| 32 |
int imin, imax; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
double xmin, xmax; |
| 37 |
uint64_t n; |
| 38 |
double *x; |
| 39 |
uint64_t nalloc; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
double phi; |
| 46 |
int cmin; |
| 47 |
uint64_t z; |
| 48 |
uint64_t Nc; |
| 49 |
uint64_t No; |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
double *expect; |
| 54 |
int emin; |
| 55 |
double tailbase; |
| 56 |
double tailmass; |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
int is_full; |
| 61 |
int is_done; |
| 62 |
int is_sorted; |
| 63 |
int is_tailfit; |
| 64 |
int is_rounded; |
| 65 |
enum { COMPLETE, VIRTUAL_CENSORED, TRUE_CENSORED } dataset_is; |
| 66 |
|
| 67 |
} ESL_HISTOGRAM; |
| 68 |
|
| 69 |
#define esl_histogram_Bin2LBound(h,b) ((h)->w*(b) + (h)->bmin) |
| 70 |
#define esl_histogram_Bin2UBound(h,b) ((h)->w*((b)+1) + (h)->bmin) |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
extern ESL_HISTOGRAM *esl_histogram_Create (double bmin, double bmax, double w); |
| 75 |
extern ESL_HISTOGRAM *esl_histogram_CreateFull(double bmin, double bmax, double w); |
| 76 |
extern void esl_histogram_Destroy (ESL_HISTOGRAM *h); |
| 77 |
extern int esl_histogram_Score2Bin(ESL_HISTOGRAM *h, double x, int *ret_b); |
| 78 |
extern int esl_histogram_Add (ESL_HISTOGRAM *h, double x); |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
extern int esl_histogram_DeclareCensoring(ESL_HISTOGRAM *h, int z, double phi); |
| 83 |
extern int esl_histogram_DeclareRounding (ESL_HISTOGRAM *h); |
| 84 |
extern int esl_histogram_SetTail (ESL_HISTOGRAM *h, double phi, |
| 85 |
double *ret_newmass); |
| 86 |
extern int esl_histogram_SetTailByMass (ESL_HISTOGRAM *h, double pmass, |
| 87 |
double *ret_newmass); |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
extern int esl_histogram_GetRank(ESL_HISTOGRAM *h, int rank, double *ret_x); |
| 92 |
extern int esl_histogram_GetData(ESL_HISTOGRAM *h, double **ret_x, int *ret_n); |
| 93 |
extern int esl_histogram_GetTail(ESL_HISTOGRAM *h, double phi, double **ret_x, |
| 94 |
int *ret_n, int *ret_z); |
| 95 |
extern int esl_histogram_GetTailByMass(ESL_HISTOGRAM *h, double pmass, |
| 96 |
double **ret_x, int *ret_n, int *ret_z); |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
extern int esl_histogram_SetExpect(ESL_HISTOGRAM *h, |
| 102 |
double (*cdf)(double x, void *params), |
| 103 |
void *params); |
| 104 |
extern int esl_histogram_SetExpectedTail(ESL_HISTOGRAM *h, double base_val, |
| 105 |
double pmass, |
| 106 |
double (*cdf)(double x, void *params), |
| 107 |
void *params); |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
extern int esl_histogram_Write (FILE *fp, ESL_HISTOGRAM *h); |
| 112 |
extern int esl_histogram_Plot (FILE *fp, ESL_HISTOGRAM *h); |
| 113 |
extern int esl_histogram_PlotSurvival(FILE *fp, ESL_HISTOGRAM *h); |
| 114 |
extern int esl_histogram_PlotQQ (FILE *fp, ESL_HISTOGRAM *h, |
| 115 |
double (*invcdf)(double, void *), void *params); |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
extern int esl_histogram_Goodness(ESL_HISTOGRAM *h, int nfitted, |
| 120 |
int *ret_nbins, |
| 121 |
double *ret_G, double *ret_Gp, |
| 122 |
double *ret_X2, double *ret_X2p); |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
#endif |