Skip to content
Snippets Groups Projects
Commit 8aaf8dcb authored by Andre Offringa's avatar Andre Offringa
Browse files

Task #1892: distribution parameters, errors etc

parent 2e336215
No related branches found
No related tags found
No related merge requests found
......@@ -100,7 +100,7 @@ class HistogramPage : public Gtk::HBox {
Gtk::Frame _fitFrame;
Gtk::VBox _fitBox;
Gtk::CheckButton _fitButton, _subtractFitButton, _fitAutoRangeButton;
Gtk::CheckButton _fitButton, _subtractFitButton, _fitLogarithmicButton, _fitAutoRangeButton;
Gtk::Entry _fitStartEntry, _fitEndEntry;
Gtk::TextView _fitTextView;
......
......@@ -44,6 +44,7 @@ HistogramPage::HistogramPage() :
_fitFrame("Fitting"),
_fitButton("Fit"),
_subtractFitButton("Subtract"),
_fitLogarithmicButton("Log fit"),
_fitAutoRangeButton("Auto range"),
_functionFrame("Function"),
_nsButton("N(S)"),
......@@ -96,6 +97,8 @@ HistogramPage::HistogramPage() :
_fitButton.signal_clicked().connect(sigc::mem_fun(*this, &HistogramPage::updatePlot));
_fitBox.pack_start(_subtractFitButton, Gtk::PACK_SHRINK);
_subtractFitButton.signal_clicked().connect(sigc::mem_fun(*this, &HistogramPage::updatePlot));
_fitBox.pack_start(_fitLogarithmicButton, Gtk::PACK_SHRINK);
_fitLogarithmicButton.signal_clicked().connect(sigc::mem_fun(*this, &HistogramPage::updatePlot));
_fitBox.pack_start(_fitAutoRangeButton, Gtk::PACK_SHRINK);
_fitAutoRangeButton.set_active(true);
_fitAutoRangeButton.signal_clicked().connect(sigc::mem_fun(*this, &HistogramPage::onAutoRangeClicked));
......@@ -314,6 +317,7 @@ void HistogramPage::plotFit(const LogHistogram &histogram, const std::string &ti
}
double sigma = sigmaEstimate, n = RayleighFitter::NEstimate(histogram, minRange, maxRange);
RayleighFitter fitter;
fitter.SetFitLogarithmic(_fitLogarithmicButton.get_active());
fitter.Fit(minRange, maxRange, histogram, sigma, n);
if(_fitButton.get_active())
{
......
......@@ -33,10 +33,9 @@ static int fit_f(const gsl_vector *xvec, void *data, gsl_vector *f)
double sigmaP2 = sigma*sigma;
double Yi = x * exp(-(x*x)/(2*sigmaP2)) * n / sigmaP2;
if(fitter.FitLogarithmic())
gsl_vector_set(f, t, (Yi - val));
else
gsl_vector_set(f, t, log(Yi) - log(val));
else
gsl_vector_set(f, t, (Yi - val));
++t;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment