75 step_size = (double) (max_val - min_val) / (double) n_steps;
86 int Xdim=(int)
XSIZE(*
this);
100 if (i < 0 || i >= Xdim)
108 std::cout <<
" hmin " <<
hmin <<
" hmax " <<
hmax <<
" value " << val
109 <<
" index " << i <<
" (step_size= " <<
step_size <<
")" << std::endl;
164 double required_mass;
169 if (percent_mass > 100)
173 if (percent_mass == 0)
175 if (percent_mass == 100)
179 required_mass = (double)
no_samples * percent_mass / 100.0;
180 int N_diff_from_0 = 0;
181 while (acc < required_mass)
190 if (acc == required_mass)
195 else if (N_diff_from_0 == 1)
228 while (current_value <= value)
249 double ipSum = 1.0 / pSum;
253 entropy -= pi *
log(pi);
266 int Nsteps=(int)
round(1.0/probStep);
267 x.resizeNoCopy(Nsteps);
268 probXLessThanx.resizeNoCopy(Nsteps);
270 for (
double p=probStep/2; p<1; p+=probStep, i++)
272 size_t idx=(size_t)
round(p*N);
278 #define INTERP(x,x0,y0,xF,yF) (y0+(x-x0)*(yF-y0)/(xF-x0)) 297 while (iLeft<=iRight)
299 int iMiddle = iLeft+(iRight-iLeft)/2;
350 std::cout <<
"Comparing at " << v <<
" (" << ih1 <<
") p1=" << p1 <<
" p2= " << p2 << std::endl;
351 std::cout <<
" hmin " << hmin <<
" hmax " << hmax <<
" stepsize " << h1.
step_size << std::endl;
354 if (p1 != 0 && p2 != 0)
366 error *= step / (hmax -
hmin);
370 std::cout <<
"Total error = " << error << std::endl;
396 int steps_no =
XSIZE(bins);
397 __binsRightLimits.initZeros(steps_no);
398 __hist.initZeros(steps_no);
401 for (
int i = 0;
i < steps_no; ++
i)
413 int binsNo =
XSIZE(__binsRightLimits);
442 for (
int i = 0;
i < binsNo; ++
i)
453 __hist *= 1.0/__hist.sum();
513 double jmin_val,
double jmax_val,
int jn_steps)
518 istep_size = (double) (imax_val - imin_val) / (double) in_steps;
523 jstep_size = (double) (jmax_val - jmin_val) / (double) jn_steps;
534 if (i == -1 || j == -1)
536 int Xdim=(int)
XSIZE(*
this);
537 int Ydim=(int)
YSIZE(*
this);
538 i =
CLIP(i, 0, Ydim);
539 j =
CLIP(j, 0, Xdim);
564 fh.open(fn.c_str(), std::ios::out);
581 double max,
int no_steps)
583 hist.
init(min, max, no_steps);
584 #define COMPUTEHIST(type) compute_hist(MULTIDIM_ARRAY_TYPE(v,type),hist,min,max,no_steps);
void insert_value(double v, double u)
void val2index(double v, int &i) const
void min(Image< double > &op1, const Image< double > &op2)
#define A2D_ELEM(v, i, j)
void resize(size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim, bool copy=true)
double KLDistance(const Histogram1D &h1, const Histogram1D &h2)
#define REPORT_ERROR(nerr, ErrormMsg)
void computeDoubleMinMax(double &minval, double &maxval) const
void init(const Histogram1D &oldHistogram, const MultidimArray< int > &bins)
Initialize class.
double mass_below(double value)
double detectability_error(const Histogram1D &h1, const Histogram1D &h2)
void assign(const Histogram1D &H)
void init(double imin_val, double imax_val, int in_steps, double jmin_val, double jmax_val, int jn_steps)
Histogram1D & operator=(const Histogram1D &H)
void setValue(const MDObject &object) override
double percentil(double percent_mass)
void index2val(double i, double j, double &v, double &u) const
Incorrect MultidimArray size.
void init(double min_val, double max_val, int n_steps)
void calculateCDF(MultidimArray< double > &V, double probStep=0.005)
Calculate the CDF of V with a probability step of 0.005 (p is between 0 and 1)
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
int val2Index(double value) const
Return the index corresponding to a certain value.
const Histogram1D & getHistogram() const
Get histogram.
void insert_value(double val)
#define DIRECT_A1D_ELEM(v, i)
friend std::ostream & operator<<(std::ostream &o, const Histogram1D &hist)
void index2val(double i, double &v) const
void log(Image< double > &op)
void compute_hist(const MultidimArrayGeneric &array, Histogram1D &hist, int no_steps)
#define INTERP(x, x0, y0, xF, yF)
double getProbability(double x)
Get the probability Pr{V<=x}.
MultidimArray< T > & operator=(const MultidimArray< T > &op1)
void max(Image< double > &op1, const Image< double > &op2)
#define DIRECT_MULTIDIM_ELEM(v, n)
void write(const FileName &fn)
void log10(Image< double > &op)
void assign(const Histogram2D &H)
void sort(struct DCEL_T *dcel)
MultidimArray< double > __binsRightLimits
#define FOR_ALL_ELEMENTS_IN_ARRAY1D(v)
void write(const FileName &fn, MDLabel=MDL_X, MDLabel=MDL_COUNT)
#define COMPUTEHIST(type)
void initZeros(const MultidimArray< T1 > &op)
void selfNormalize()
Normalize to be a probability density function.
Incorrect value received.
Histogram2D & operator=(const Histogram2D &H)
#define SWITCHDATATYPE(datatype, OP)