33 return p[0]*std::exp(-0.5*std::pow(t-p[1], 2)/std::pow(p[2], 2));
44 return p[0] * std::pow(p[1], 2)/(std::pow(t - p[2], 2) + std::pow(p[1], 2));
55 const std::complex<double> i(0.0, 1.0);
56 std::complex<double> z = (t - p[1] + i*p[3]) / (p[2] * arma::datum::sqrt2);
57 return p[0] *
Faddeeva::w(z).real() / (p[2] * arma::datum::sqrt2);
68 arma::vec logy = arma::log(y);
72 double A = std::exp(quad_params(0) - (0.25*std::pow(quad_params(1), 2)/quad_params(2)));
73 double sigma = (quad_params(2) < 0 ? std::sqrt(-0.5/quad_params(2)) : arma::stddev(y));
74 double mu = -0.5*quad_params(1)/quad_params(2);
76 return arma::vec({A, mu, sigma});
84 double x0 = -0.5 * quad_params(1) / quad_params(0);
85 double inside_sqrt = (quad_params(2) - std::pow(x0, 1)) / quad_params(0);
86 double gamma = (inside_sqrt >= 0 ? std::sqrt(inside_sqrt) : arma::stddev(y));
87 double I = 1.0 / (quad_params(0) * gamma);
88 return arma::vec({I, gamma, x0});
double GaussianFn(double t, const double *p)
Gaussian.
VESPUCCI_EXPORT arma::vec FitLorentzian(arma::vec x, arma::vec y)
double VoigtFn(double t, const double *p)
VoigtFn.
VESPUCCI_EXPORT arma::uword max(arma::uword a, arma::uword b)
Vespucci::Math::max.
VESPUCCI_EXPORT arma::vec EstimateGaussParams(arma::vec x, arma::vec y)
Vespucci::Math::NonLinLeastSq::EstimateGaussParams.
VESPUCCI_EXPORT arma::vec EstimateLorentzParams(arma::vec x, arma::vec y)
VESPUCCI_EXPORT arma::vec FitGaussian(arma::vec x, arma::vec y)
Vespucci::Math::NonLinLeastSq::FitGaussian.
double LorentzianFn(double t, const double *p)
Lorentzian.
std::complex< double > w(std::complex< double > z, double relerr=0)
VESPUCCI_EXPORT arma::mat Vandermonde(const arma::vec &x, const int poly_order)
Vespucci::Math::LinLeastSq::Vandermonde Build a Vandermonde matrix for OLS.
VESPUCCI_EXPORT arma::mat OrdinaryLeastSquares(const arma::mat &X, const arma::mat &y)
Vespucci::Math::LinLeastSq::OrdinaryLeastSquares Perform Squares.
VESPUCCI_EXPORT arma::vec FitVoigt(arma::vec x, arma::vec y)