Beschreibung:
Dieses Snippet soll die wichtigsten Verteilungen darstellen, ich war mal auf der Suche danach und habe nichts gefunden, desshalb das Snippet 😉
**
TRIANGULAR , DREIECK VERTEILUNG**
public double Low { get; protected set; }
public double Medium { get; protected set; } //PEAK
public double High { get; protected set; }
public double Width
{
get { return High - Low; }
}
public Dreieck(double low, double medium, double high)
{
Low = low;
Medium = medium;
High = high;
}
public double GetY(double x)
{
//case 1
if (Low <= x && x <= Medium)
{
return (2 * (x - Low)) / ((High - Low) * (Medium - Low));
}
//case 2
if (Medium < x && x <= High)
{
return (2 * (High - x)) / ((High - Low) * (High - Medium));
}
return 0;
}
public List<Props.Matrix> GetTable()
{
List<Props.Matrix> result = new List<Props.Matrix>();
for (double x = Low; x < High; x++)
{
result.Add(new Props.Matrix(x, GetY(x)));
}
return result;
}
public List<Props.Matrix> Get3PointTable()
{
List<Props.Matrix> result = new List<Props.Matrix>();
result.Add(new Props.Matrix(Low, 0));
result.Add(new Props.Matrix(Medium, Medium));
result.Add(new Props.Matrix(High, 0));
return result;
}
(Get3PointTable ist aus Performance-Gründen hier, damit man ein z.B Chart Control nicht unötig lange Punkte zeichnen lässt)
**
FIXED HEIGHT, FESTE HÖHE**
public double Wert { get; protected set; }
public FesteHoehe(double wert)
{
Wert = wert;
}
public double GetY(double x)
{
return x;
}
public List<Props.Matrix> GetTable()
{
List<Props.Matrix> result = new List<Props.Matrix>();
for (double x = 0; x < Wert; x += 10)
{
result.Add(new Props.Matrix(0, GetY(x)));
}
return result;
}
public List<Props.Matrix> Get1PointTable()
{
List<Props.Matrix> result = new List<Props.Matrix>();
result.Add(new Props.Matrix(0, Wert));
return result;
}
public string GetName()
{
return "Feste_Hoehe";
}
(Get1PointTable ist aus Performance-Gründen hier, damit man ein z.B Chart Control nicht unötig lange Punkte zeichnen lässt)
**
NORMAL, GAUSSIAN NORMAL**
public double Deviation { get; protected set; }
public double Mean { get; protected set; }
private double _next = Double.NaN;
public Gaussian_Normal(double mean, double deviation)
{
Deviation = deviation;
Mean = mean;
}
public double GetY(double x)
{
//return Math.Exp(-(Math.Pow((x - Mean) / Deviation, 2) / 2)) / Math.Sqrt(2 * Math.PI) / Deviation;
x = (x - Mean) / Deviation; // normierung
return SQRT_2PI * Math.Exp(-0.5 * x * x) / Deviation;
}
public List<Props.Matrix> GetTable()
{
double from = Mean - Deviation * 3;
double to = Mean + Deviation * 3;
List<Props.Matrix> result = new List<Props.Matrix>();
for (double x = from; x <= to; x += .05 * (to - from))
{
result.Add(new Props.Matrix(x, GetY(x)));
}
return result;
}
public string GetName()
{
return "Gaussian_Normal";
}
**
LOGNORMAL**
public double Deviation { get; protected set; }
public double Mean { get; protected set; }
public LogNormal(double mean, double deviation)
{
Deviation = deviation;
Mean = mean;
}
public double GetY(double x)
{
return Math.Exp(-Math.Pow(Math.Log(x) - Mean, 2.0) / 2.0 / Deviation / Deviation) / x / Deviation / SQRT_2PI; // 2*pi
}
public List<Props.Matrix> GetTable()
{
double from = Math.Exp(Mean - Deviation * 3);
double to = Math.Exp(Mean + Deviation * 3);
List<Props.Matrix> result = new List<Props.Matrix>();
for (double x = from; x <= to; x += 0.1)
{
result.Add(new Props.Matrix(x, GetY(x)));
}
return result;
}
public string GetName()
{
return "Log_Normal";
}
Gegenbenfalls findet ja jemand Verwendung dafür 😉
Beste Grüsse
Diräkt
Schlagwörter: verteilungen,triangular,normal,lognormal,gaussian,fixed heighet,feste höhe,dreieck