Commit a2cc20c9 authored by Stefan Gerlach's avatar Stefan Gerlach

merge fixes

parents e386e3e9 f73de389
......@@ -257,7 +257,7 @@ QString FileDataSource::fileInfoString(const QString &name){
QStringList infoStrings;
//general information about the file
infoStrings << i18n("<u><b>%1:</b></u>", fileName);
infoStrings << "<u><b>" + fileName + "</b></u><br>";
fileInfo.setFile(fileName);
infoStrings << i18n("Readable: %1", fileInfo.isReadable() ? i18n("yes") : i18n("no"));
......
......@@ -125,6 +125,7 @@ void ExpressionParser::initFunctions() {
m_functionsNames << i18n("Power function [x^y]");
m_functionsNames << i18n("Nonnegative square root");
m_functionsNames << i18n("Sign function");
m_functionsNames << i18n("Heavyside theta function");
#ifndef HAVE_WINDOWS
m_functionsNames << i18n("Cube root");
......@@ -146,9 +147,9 @@ void ExpressionParser::initFunctions() {
m_functionsNames << QString("x^9");
#ifndef HAVE_WINDOWS
for (int i = 0; i < 25; i++)
for (int i = 0; i < 26; i++)
#else
for (int i = 0; i < 20; i++)
for (int i = 0; i < 21; i++)
#endif
m_functionsGroupIndex << 0;
......
......@@ -57,6 +57,12 @@ double my_sgn(double x) {
return 0;
}
#endif
double my_theta(double x) {
if (x >= 0)
return 1;
else
return 0;
}
/* missing trig. functions */
double my_sec(double x) { return 1./cos(x); }
......@@ -189,6 +195,7 @@ struct func _functions[] = {
{"pow", pow},
{"sqrt", sqrt},
{"sgn", my_sgn},
{"theta", my_theta},
#ifndef _WIN32
{"cbrt", cbrt},
{"logb", logb},
......
......@@ -300,6 +300,21 @@ double nsl_fit_model_gudermann_param_deriv(int param, double x, double s, double
}
/* distributions */
double nsl_fit_model_gaussian_tail_param_deriv(int param, double x, double s, double mu, double A, double a, double sigma) {
if (x < a)
return 0;
double s2 = s*s, N = erfc(a/s/M_SQRT2)/2., norm = 1./sqrt(2.*M_PI)/s/sigma/N, efactor = exp(-(x-mu)*(x-mu)/(2.*s2));
if (param == 0)
return A * norm/(s*s2) * ((x-mu)*(x-mu) - s2) * efactor;
if (param == 1)
return A * norm/s2 * (x-mu) * efactor;
if (param == 2)
return norm * efactor;
if (param == 3)
return A/norm/norm * efactor * exp(-a*a/(2.*s2));
return 0;
}
double nsl_fit_model_maxwell_param_deriv(int param, double x, double a, double c, double sigma) {
double a2 = a*a, a3 = a*a2, norm = sqrt(2./M_PI)/a3/sigma, x2 = x*x, efactor = exp(-x2/2./a2);
......
......@@ -84,6 +84,7 @@ double nsl_fit_model_hill_param_deriv(int param, double x, double s, double n, d
double nsl_fit_model_gompertz_param_deriv(int param, double x, double a, double b, double c, double sigma);
double nsl_fit_model_gudermann_param_deriv(int param, double x, double s, double mu, double a, double sigma);
/* distributions */
double nsl_fit_model_gaussian_tail_param_deriv(int param, double x, double s, double mu, double A, double a, double sigma);
double nsl_fit_model_poisson_param_deriv(int param, double x, double l, double a, double sigma);
double nsl_fit_model_lognormal_param_deriv(int param, double x, double b, double mu, double a, double sigma);
double nsl_fit_model_gamma_param_deriv(int param, double x, double t, double k, double a, double sigma);
......
......@@ -41,7 +41,7 @@ const char* nsl_sf_stats_distribution_pic_name[] = {
"pareto", "weibull", "gumbel1", "gumbel2", "poisson", "bernoulli", "binomial", "binomial_negative", "pascal", "geometric",
"hypergeometric", "logarithmic", "maxwell_boltzmann", "sech", "levy", "frechet"};
const char* nsl_sf_stats_distribution_equation[] = {
"a/sqrt(2*pi)/s * exp(-((x-mu)/s)^2/2)", "Gaussian tail", "Exponential",
"a/sqrt(2*pi)/s * exp(-((x-mu)/s)^2/2)", "2*A/sqrt(2*pi)/s/erfc(a/sqrt(2)/s) * exp(-((x-mu)/s)^2/2) * theta(x-mu-a)", "Exponential",
"a/(2*s) * exp(-fabs((x-mu)/s))", "Exp power", "a/pi * g/(g^2 + (x-mu)^2)",
"a * x/s^2 * exp(-(x/s)^2/2)", "Rayleigh tail", "Landau",
"Levy alpha-stable", "Levy-skew", "a/gamma(k)/t^k * x^(k-1)*exp(-x/t)",
......
......@@ -96,7 +96,7 @@ QVariant SpreadsheetModel::data(const QModelIndex& index, int role) const {
case Qt::ToolTipRole: {
if(col_ptr->isValid(row)) {
if(col_ptr->isMasked(row))
return QVariant(col_ptr->asStringColumn()->textAt(row) + i18n(", masked (ignored in all operations)"));
return QVariant(i18n("%1, masked (ignored in all operations)").arg(col_ptr->asStringColumn()->textAt(row)));
else
return QVariant(col_ptr->asStringColumn()->textAt(row));
} else {
......
......@@ -576,6 +576,24 @@ int func_df(const gsl_vector* paramValues, void* params, gsl_matrix* J) {
}
break;
}
case nsl_sf_stats_gaussian_tail: {
double s = nsl_fit_map_bound(gsl_vector_get(paramValues, 0), min[0], max[0]);
double mu = nsl_fit_map_bound(gsl_vector_get(paramValues, 1), min[1], max[1]);
double A = nsl_fit_map_bound(gsl_vector_get(paramValues, 2), min[2], max[2]);
double a = nsl_fit_map_bound(gsl_vector_get(paramValues, 3), min[3], max[3]);
for (size_t i = 0; i < n; i++) {
x = xVector[i];
if (sigmaVector) sigma = sigmaVector[i];
for (int j = 0; j < 4; j++) {
if (fixed[j])
gsl_matrix_set(J, i, j, 0.);
else
gsl_matrix_set(J, i, j, nsl_fit_model_gaussian_tail_param_deriv(j, x, s, mu, A, a, sigma));
}
}
break;
}
case nsl_sf_stats_rayleigh: {
double s = nsl_fit_map_bound(gsl_vector_get(paramValues, 0), min[0], max[0]);
double a = nsl_fit_map_bound(gsl_vector_get(paramValues, 1), min[1], max[1]);
......@@ -716,7 +734,6 @@ int func_df(const gsl_vector* paramValues, void* params, gsl_matrix* J) {
break;
}
// TODO
case nsl_sf_stats_gaussian_tail:
case nsl_sf_stats_exponential:
case nsl_sf_stats_exponential_power:
case nsl_sf_stats_rayleigh_tail:
......
......@@ -72,6 +72,15 @@ MatrixView::MatrixView(Matrix* matrix) : QWidget(),
m_imageIsDirty(true) {
init();
//resize the view to show a 10x10 region of the matrix.
//no need to resize the view when the project is being opened,
//all views will be resized to the stored values at the end
if (!m_matrix->isLoading()) {
int w = m_tableView->horizontalHeader()->sectionSize(0)*10 + m_tableView->verticalHeader()->width();
int h = m_tableView->verticalHeader()->sectionSize(0)*10 + m_tableView->horizontalHeader()->height();
resize(w+50, h+50);
}
}
MatrixView::~MatrixView() {
......
......@@ -100,7 +100,7 @@ SpreadsheetView::SpreadsheetView(Spreadsheet *spreadsheet):QWidget(),
else
h += m_tableView->verticalHeader()->sectionSize(0)*m_tableView->verticalHeader()->count();
resize(w*1.1, h);
resize(w+50, h);
}
}
......
......@@ -3,7 +3,7 @@
Project : LabPlot
Description : Worksheet view
--------------------------------------------------------------------
Copyright : (C) 2009-2016 Alexander Semke (alexander.semke@web.de)
Copyright : (C) 2009-2017 Alexander Semke (alexander.semke@web.de)
Copyright : (C) 2016 Stefan-Gerlach (stefan.gerlach@uni.kn)
***************************************************************************/
......
......@@ -3,8 +3,8 @@
Project : LabPlot
Description : import file data dialog
--------------------------------------------------------------------
Copyright : (C) 2008 by Stefan Gerlach
Email (use @ for *) : stefan.gerlach*uni-konstanz.de, alexander.semke*web.de
Copyright : (C) 2009-2017 by Alexander Semke (alexander.semke@web.de)
Copyright : (C) 2015-2016 Stefan-Gerlach (stefan.gerlach@uni.kn)
***************************************************************************/
......
......@@ -365,7 +365,7 @@ void XYFitCurveDock::categoryChanged(int index) {
for(int i = 1; i < NSL_SF_STATS_DISTRIBUTION_COUNT; i++) {
//TODO: implement following distribution models
if (i == nsl_sf_stats_gaussian_tail || i == nsl_sf_stats_exponential || i == nsl_sf_stats_exponential_power ||
if (i == nsl_sf_stats_exponential || i == nsl_sf_stats_exponential_power ||
i == nsl_sf_stats_rayleigh_tail || i == nsl_sf_stats_landau || i == nsl_sf_stats_levy_alpha_stable ||
i == nsl_sf_stats_levy_skew_alpha_stable || i == nsl_sf_stats_flat || i == nsl_sf_stats_fdist ||
i == nsl_sf_stats_tdist || i == nsl_sf_stats_beta || i == nsl_sf_stats_gumbel2 || i == nsl_sf_stats_bernoulli ||
......@@ -721,7 +721,7 @@ void XYFitCurveDock::updateModelEquation() {
break;
case nsl_fit_model_distribution:
switch ((nsl_sf_stats_distribution)m_fitData.modelType) {
// TODO: add missing GSL distributions
// TODO: add missing GSL distributions (see nsl_sf_stats.c)
case nsl_sf_stats_gaussian:
case nsl_sf_stats_laplace:
case nsl_sf_stats_lognormal:
......@@ -731,6 +731,9 @@ void XYFitCurveDock::updateModelEquation() {
m_fitData.paramNamesUtf8 << QString::fromUtf8("\u03c3") << QString::fromUtf8("\u03bc") << "A";
break;
case nsl_sf_stats_gaussian_tail:
m_fitData.paramNames << "s" << "mu" << "A" << "a";
m_fitData.paramNamesUtf8 << QString::fromUtf8("\u03c3") << QString::fromUtf8("\u03bc") << "A" << "a";
break;
case nsl_sf_stats_exponential:
case nsl_sf_stats_exponential_power:
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment