1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include <iostream>
#include <cmath>
#include <fityk/fityk.h>
using namespace std;
using namespace fityk;
int main()
{
Fityk *f = new Fityk;
cout << f->get_info("version") << endl;
cout << "ln(2) = " << f->calculate_expr("ln(2)") << endl;
const double mu = 12.345;
for (int i = 0; i != 500; ++i) {
double x = i / 100. + 10;
double y = ceil(100 * exp(-(x-mu)*(x-mu)/2));
f->add_point(x, y, sqrt(y));
}
f->execute("Y = randnormal(y, s)");
f->execute("guess %gauss = Gaussian");
f->execute("fit");
cout << "peak center: " << f->calculate_expr("%gauss.Center") << endl;
cout << "value at x=12: " << f->get_function("gauss")->value_at(12) << endl;
delete f;
return 0;
}
|