2016-06-12 10 views
0

Ich habe eine Exception error (überraschend) während der Durchführung einiger paralleler statistischer Tests mit Math.Net Numerics erlebt, und ich würde gerne die Begründung kennen.MATH.NET Numerics Stable Distributionen. Ausnahme vom Typ 'System.NotSupportedException'

using MathNet.Numerics.Distributions; 
.... 
var stable = new Stable(1.7, -0.7, 0.0087, 0.9103); 
     double b = stable.Density(3.2); 
     double a = stable.Density(5.1); 
     Console.WriteLine(b); 
     Console.WriteLine(a); 

Fehler: Eine nicht behandelte Ausnahme des Typs System.NotSupportedException aufgetreten in MathNet.Numerics.dll

Ich erwartete b = 2.2484e-06 zu bekommen, a = 4.3977e-07.

Ps: Andere klassische Distributionen wie Gamma Arbeit ohne Problem (zB Probability Distributions), Urteil aus de facto jede Installation Problem mit dem Paket

Best,

EDIT: Aus Github repository Ich habe hinzugefügt Stable.cs in meinem Projekt, das alle Eigenschaften und Methoden enthält.

Faktisch funktionieren die Eigenschaften gut. Siehe Abbildung unten von Program.cs:

Stable st = new Stable(1.7, -0.7, 0.0087, 0.9103); // correct instantiation 

    Console.WriteLine(string.Format(" Characteristic exponent: {0}\n 
    Skewness: {1}\n Scale: {2}\n Location: {3}" ,st.Alpha, st.Beta, 
    st.Scale,st.Location)); 

Allerdings gibt es nichts unlogisch, so weit es mich betrifft, in der Density Methode auf dem object basierend Aufruf: st.Density(3.2), die zurückkehren soll:

PDF(_alpha, _beta, _scale, _location, x); 

So ist es verlockend, ein method definition Problem zu beenden, es sei denn, Menschen widersprechen diese Meinung mit gültigen Abbildung.

Darüber hinaus auf besondere Werte des stable parameters (z _alpha = 2.0 usw.) die definierte PDF kehrt 0 (komisch)

Antwort

0

Die Antwort liegt in der Math.NET GitHub repository.

Ihr Beispiel erfüllt die Density Formelbedingungen nicht.

public double Density(double x) 
{ 
    return PDF(_alpha, _beta, _scale, _location, x); 
} 

/// <summary> 
/// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x. 
/// </summary> 
/// <param name="alpha">The stability (α) of the distribution. Range: 2 ≥ α > 0.</param> 
/// <param name="beta">The skewness (β) of the distribution. Range: 1 ≥ β ≥ -1.</param> 
/// <param name="scale">The scale (c) of the distribution. Range: c > 0.</param> 
/// <param name="location">The location (μ) of the distribution.</param> 
/// <param name="x">The location at which to compute the density.</param> 
/// <returns>the density at <paramref name="x"/>.</returns> 
/// <seealso cref="Density"/> 
public static double PDF(double alpha, double beta, double scale, double location, double x) 
{ 
    if (alpha <= 0.0 || alpha > 2.0 || beta < -1.0 || beta > 1.0 || scale <= 0.0) 
    { 
     throw new ArgumentException(Resources.InvalidDistributionParameters); 
    } 

    if (alpha == 2d) 
    { 
     return Normal.PDF(location, Constants.Sqrt2*scale, x); 
    } 

    if (alpha == 1d && beta == 0d) 
    { 
     return Cauchy.PDF(location, scale, x); 
    } 

    if (alpha == 0.5d && beta == 1d && x >= location) 
    { 
     return (Math.Sqrt(scale/Constants.Pi2)*Math.Exp(-scale/(2*(x - location))))/Math.Pow(x - location, 1.5); 
    } 

    throw new NotSupportedException(); 
} 
+0

siehe den bearbeiteten Thread '@ rexilion'. –

Verwandte Themen