The ‘noise_gen’ function generates a spectrum of noise. This is done by taking white noise (normally distributed, uncorrelated) in the time domain and processing it according to the acquisition and processing parameters for a given spectrum. Acquisition and processing information is provided in a ‘par’ structure, which contains the fields ‘par.dX’ for each dimension X. Note that no information on signal decay is necessary. The result is then very similar to spectrum noise, although discrepancies may occur because of the presence of artifacts, and any frequency filtering within the spectral width. The format of the output of ‘noise_gen’ follows that of all ‘spec’ variables. Note that the frequency axes are arbitrary, so they will always be centered at a frequency of zero. The noise returned by ‘noise_gen’ will always have an rms of 1.
To generate a noise spectrum:
noise_spec=noise_gen(par);
Noise generation is useful for visual evaluation of fit quality. This is because the form of the spectrum noise heavily influences the appearance of lineshapes with low signal to noise. Furthermore, the FitSpec function may opt to fit a spectrum feature that appears to be the result of overlapping peaks with only a single peak, and when a fit is viewed with spectrum noise, it becomes apparent that the feature is likely to be a result of a single peak and spectrum noise. The following example demonstrates how to generate a calculated spectrum with noise after spectrum fitting. Note that if FitSpec runs a noise evaluation, then the output variable, ‘fit’, contains the rms of the input spectrum.
fit=FitSpec(spec);
calc_spec=fit.spec;
noise_spec=noise_gen(calc_spec.par);
calc_spec.S=add_spec_nD(calc_spec,noise_spec,[1 fit.noise.rms]);
Here, we have taken the fitted spectrum out of the results from FitSpec. Then, a noise spectrum is generated, using the acquisition and processing parameters of the calculated spectrum (these are the same as the original spectrum). Finally, the calculated spectrum and the noise spectrum are added together, using ‘add_spec_nD’, with a weight of 1 for the calculated spectrum and a weight of the spectrum RMS (fit.noise.rms) for the noise spectrum, so that the synthetic spectrum has the same noise level as the original experimental spectrum.