Exemple #1
0
void MultiPeakFit::guessInitialValues()
{
	if (!d_n || d_peaks > 1)
		return;

	size_t imin, imax;
	gsl_stats_minmax_index(&imin, &imax, d_y, 1, d_n);

	double min_out = d_y[imin];
	double max_out = d_y[imax];

	QVarLengthArray<double> temp(d_n);//double temp[d_n];
	for (int i = 0; i < d_n; i++)
		temp[i] = fabs(d_y[i]);
	size_t imax_temp = gsl_stats_max_index(temp.data(), 1, d_n);//size_t imax_temp = gsl_stats_max_index(temp, 1, d_n);

	double offset, area;
	if (imax_temp == imax)
		offset = min_out;
	else //reversed bell
		offset = max_out;

	double xc = d_x[imax_temp];
	double width = 2*gsl_stats_sd(d_x, 1, d_n);

	if (d_profile == Lorentz)
		area = M_PI_2*width*fabs(max_out - min_out);
	else
		area = sqrt(M_PI_2)*width*fabs(max_out - min_out);

	gsl_vector_set(d_param_init, 0, area);
	gsl_vector_set(d_param_init, 1, xc);
	gsl_vector_set(d_param_init, 2, width);
	gsl_vector_set(d_param_init, 3, offset);
}
Exemple #2
0
void GaussAmpFit::guessInitialValues()
{
	size_t imin, imax;
	gsl_stats_minmax_index(&imin, &imax, d_y, 1, d_n);

	double min_out = d_y[imin];
	double max_out = d_y[imax];

	gsl_vector_set(d_param_init, 1, fabs(max_out - min_out));

#ifdef Q_CC_MSVC
	QVarLengthArray<double> temp(d_n);
#else
	double temp[d_n];
#endif
	for (int i = 0; i < d_n; i++)
		temp[i] = fabs(d_y[i]);
#ifdef Q_CC_MSVC
	size_t imax_temp = gsl_stats_max_index(temp.data(), 1, d_n);
#else
	size_t imax_temp = gsl_stats_max_index(temp, 1, d_n);
#endif

	gsl_vector_set(d_param_init, 2, d_x[imax_temp]);
	gsl_vector_set(d_param_init, 3, gsl_stats_sd(d_x, 1, d_n));

	if (imax_temp == imax)
		gsl_vector_set(d_param_init, 0, min_out);
	else //reversed bell
		gsl_vector_set(d_param_init, 0, max_out);
}
Exemple #3
0
CAMLprim value ml_gsl_stats_minmax_index(value data)
{
  size_t len = Double_array_length(data);
  size_t mi, ma;
  value r;
  gsl_stats_minmax_index(&mi, &ma, Double_array_val(data), 1, len);
  r = alloc_small(2, 0);
  Field(r, 0) = Val_int(mi);
  Field(r, 1) = Val_int(ma);
  return r;
}
void GaussAmpFit::guessInitialValues()
{
	size_t imin, imax;
	gsl_stats_minmax_index(&imin, &imax, d_y, 1, d_n);

	double min_out = d_y[imin];
	double max_out = d_y[imax];

	gsl_vector_set(d_param_init, 1, fabs(max_out - min_out));

	double temp[d_n];
	for (int i = 0; i < d_n; i++)
		temp[i] = fabs(d_y[i]);
	size_t imax_temp = gsl_stats_max_index(temp, 1, d_n);

	gsl_vector_set(d_param_init, 2, d_x[imax_temp]);
	gsl_vector_set(d_param_init, 3, gsl_stats_sd(d_x, 1, d_n));

	if (imax_temp == imax)
		gsl_vector_set(d_param_init, 0, min_out);
	else //reversed bell
		gsl_vector_set(d_param_init, 0, max_out);
}
Exemple #5
0
pure_expr* wrap_gsl_stats_minmax_index(double* data, size_t n)
{
  size_t x, y;
  gsl_stats_minmax_index(&x, &y, data, 1, n);
  return pure_listl(2, pure_int(x), pure_int(y));
}