21 typedef std::vector<DataPoint>
Data;
32 void init(
double parzenWindow) {
51 for (Data::const_iterator it =
m_data.begin(); it !=
m_data.end(); it++) {
57 for (Data::iterator it =
m_data.begin(); it !=
m_data.end(); it++) {
65 void add(
double x,
double p) {
95 assert(
m_data.size() > 0 );
99 for (Data::const_iterator it =
m_data.begin(); it !=
m_data.end(); it++) {
101 double dist = fabs(x - d.
x);
113 assert(
m_data.size() > 0 );
129 assert(
m_data.size() > 0 );
131 std::vector<double>::iterator cit =
m_cummulated.begin();
133 for (Data::const_iterator it =
m_data.begin(); it !=
m_data.end(); ++it) {
142 assert(
m_data.size() > 0 );
167 assert(
m_data.size() > 0 );
175 std::vector<double> randoms(num);
176 for (
int i=0; i<num; i++)
179 std::sort(randoms.begin(), randoms.end());
186 while (i<nCum && j < num) {
189 while (sum >= randoms[j] && j < num) {
201 assert(
m_data.size() > 0 );
217 var +=
sqr(
x-*mean) * d;
224 double gauss(
double x,
double mean,
double sigma) {
225 return 1.0/(sqrt(2.0*M_PI)*sigma) * exp(-0.5 *
sqr( (x-mean)/sigma));
240 g =
gauss(
x, mean, sigma);
243 p +=
sqr( (sint - gint) );
261 g = 1e-10 +
gauss(
x, mean, sigma);
272 if (fabs(sd-sg) > 0.1)
281 for (Data::const_iterator it =
m_data.begin(); it !=
m_data.end(); it++) {
283 fprintf(fp,
"%f %f\n", d.
x, d.
y);
double sampleUniformDouble(double min, double max)
double kldToGauss(double step, double mean, double sigma)
void add(double x, double p)
void gnuplotDumpData(FILE *fp)
void sampleMultiple(std::vector< double > &samples, int num)
double sampleGaussian(double sigma, unsigned int S=0)
void approxGauss(double step, double *mean, double *sigma)
double gauss(double x, double mean, double sigma)
double integral(double step, double xTo)
double cramerVonMisesToGauss(double step, double mean, double sigma)
void init(double parzenWindow)
std::vector< DataPoint > Data
void integrate(double step)
double smoothedData(double x)
double sampleNumeric(double step)
DataSmoother(double parzenWindow)
DataPoint(double _x=0.0, double _y=0.0)
void gnuplotDumpSmoothedData(FILE *fp, double step)
std::vector< double > m_cummulated