array1D method
Returns a one-dimensional mixed Gauss-Lorentz shape consisting of
npoints
defined by:
a
- amplitude,
c
- center,
w
- width,
m
- mixing factors (0 <= m <= 1).
If m=1 (pure Lorentzian) then w is the "Lorentzian width". If m=0 (pure Gaussian), then w is the "Gaussian sigma".
If noiseAmpl
is not null, random noise will be added to each point
whose amplitude is controlled by this parameter, e.g. 0.005, as fraction
of the current shape value.
fGauss
and fLorentz
will take on default values if omitted.
Different literature references are using different defaults. The factors
used here ensure that w
is the line width at half maximum height
for L, G, and mixed mode.
Implementation
static Float64List array1D(
int npoints, double a, double c, double w, double m, double noiseAmpl,
[double fGauss, double fLorentz]) {
LorentzGauss lg = LorentzGauss.fromPars(a, [c], [w], [m], fGauss, fLorentz);
Float64List yvals = Float64List(npoints);
math.Random rand = math.Random();
for (int i = 0; i < npoints; i++) {
double x = i.toDouble();
yvals[i] = lg.getValueAt([x]);
if (noiseAmpl != null) {
double noise = (2 * rand.nextDouble() - 1.0) * yvals[i] * noiseAmpl;
yvals[i] += noise;
}
}
return yvals;
}