namespace Gauss { using System; using System.Windows.Data; public class Gaussian : IValueConverter { private double mean; private double variance; private double magnitude; public Gaussian() { } public Gaussian(double mean, double variance, double magnitude) { this.mean = mean; this.variance = variance; this.magnitude = magnitude; } public double Mean { get { return this.mean; } set { this.mean = value; } } public double Variance { get { return this.variance; } set { this.variance = value; } } public double Magnitude { get { return this.magnitude; } set { this.magnitude = value; } } public double Compute(double variate) { double power = -Math.Pow(variate - this.Mean, 2) / (2 * this.Variance * this.Variance); return this.magnitude * Math.Pow(Math.E, power); } public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { double val; if (value is int) val = (int)value; else val = (double)value; return this.Compute(val); } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new Exception("The method or operation is not implemented."); } } }