/// <summary> /// The add peak. /// </summary> /// <param name="yData"> /// The y data. /// </param> /// <param name="xMin"> /// The x min. /// </param> /// <param name="xStep"> /// The x step. /// </param> /// <param name="peakDescription"> /// The peak description. /// </param> private static void AddPeak(double[] yData, double xMin, double xStep, PeakDescription peakDescription) { var xStart = peakDescription.RetentionTime - 3 * peakDescription.Width; var xStop = peakDescription.RetentionTime + 3 * peakDescription.Width; var startIndex = Math.Max(0, (int)((xStart - xMin) / xStep)); var stopIndex = Math.Min(yData.Length - 1, (int)((xStop - xMin) / xStep)); for (var i = startIndex; i <= stopIndex; ++i) { var x = xMin + i * xStep; yData[i] += peakDescription.Height * Math.Exp( -(peakDescription.RetentionTime - x) * (peakDescription.RetentionTime - x) / (peakDescription.Width * peakDescription.Width)); } }
/// <summary> /// The create peak desctiptions. /// </summary> /// <param name="numberOfPeaks"> /// The number of peaks. /// </param> /// <param name="minWidth"> /// The min width. /// </param> /// <param name="maxWidth"> /// The max width. /// </param> /// <param name="minHeight"> /// The min height. /// </param> /// <param name="maxHeight"> /// The max height. /// </param> /// <param name="min"> /// The min. /// </param> /// <param name="max"> /// The max. /// </param> public static PeakDescription[] CreatePeakDesctiptions( int numberOfPeaks, double minWidth, double maxWidth, double minHeight, double maxHeight, double min, double max) { var random = new Random(); var peaks = new PeakDescription[numberOfPeaks]; for (var i = 0; i < numberOfPeaks; ++i) { var retentionTime = min + maxWidth + random.NextDouble() * (max - min - 2 * maxWidth); var height = minHeight + random.NextDouble() * (maxHeight - minHeight); var width = minWidth + random.NextDouble() * (maxWidth - minWidth); peaks[i] = new PeakDescription { Height = height, Width = width, RetentionTime = retentionTime }; } return(peaks); }