/// <summary> /// Sets properties and attributes of class in accordance with XML definition. /// </summary> /// <param name="Definition">XML definition</param> public override Task FromXml(XmlElement Definition) { this.t0 = XML.Attribute(Definition, "t0", 0.0); this.k = XML.Attribute(Definition, "k", 0.0); this.kHalf = this.k / 2; this.c = 1.0 / StatMath.Γ(this.kHalf); return(base.FromXml(Definition)); }
public void Test_01_Γ() { // https://dlmf.nist.gov/5.4 Assert.IsTrue(Math.Abs(StatMath.Γ(1) - 1) < 1e-10); Assert.IsTrue(Math.Abs(StatMath.Γ(1.0 / 2) - 1.77245385090551602729) < 1e-10); Assert.IsTrue(Math.Abs(StatMath.Γ(1.0 / 3) - 2.67893853470774763365) < 1e-10); Assert.IsTrue(Math.Abs(StatMath.Γ(2.0 / 3) - 1.35411793942640041694) < 1e-10); Assert.IsTrue(Math.Abs(StatMath.Γ(1.0 / 4) - 3.62560990822190831193) < 1e-10); Assert.IsTrue(Math.Abs(StatMath.Γ(3.0 / 4) - 1.22541670246517764512) < 1e-10); }
/// <summary> /// Sets properties and attributes of class in accordance with XML definition. /// </summary> /// <param name="Definition">XML definition</param> public override Task FromXml(XmlElement Definition) { this.t0 = XML.Attribute(Definition, "t0", 0.0); if (Definition.HasAttribute("k") && Definition.HasAttribute("θ")) { this.k = XML.Attribute(Definition, "k", 0.0); this.θ = XML.Attribute(Definition, "θ", 0.0); if (Definition.HasAttribute("α") || Definition.HasAttribute("β") || Definition.HasAttribute("μ")) { throw new Exception("Too many parameters in Gamma distribution definition."); } this.α = this.k; this.β = 1 / this.θ; this.μ = this.k * this.θ; } else if (Definition.HasAttribute("α") && Definition.HasAttribute("β")) { this.α = XML.Attribute(Definition, "α", 0.0); this.β = XML.Attribute(Definition, "β", 0.0); if (Definition.HasAttribute("k") || Definition.HasAttribute("θ") || Definition.HasAttribute("μ")) { throw new Exception("Too many parameters in Gamma distribution definition."); } this.k = this.α; this.θ = 1 / this.β; this.μ = this.α / this.β; } else if (Definition.HasAttribute("k") && Definition.HasAttribute("μ")) { this.k = XML.Attribute(Definition, "k", 0.0); this.μ = XML.Attribute(Definition, "μ", 0.0); if (Definition.HasAttribute("α") || Definition.HasAttribute("β") || Definition.HasAttribute("θ")) { throw new Exception("Too many parameters in Gamma distribution definition."); } this.α = this.k; this.β = this.α / this.μ; this.θ = this.μ / this.k; } this.invGammaAlpha = 1.0 / StatMath.Γ(this.α); return(base.FromXml(Definition)); }
/// <summary> /// Evaluates the function on two scalar arguments. /// </summary> /// <param name="Argument1">Function argument 1.</param> /// <param name="Argument2">Function argument 2.</param> /// <param name="Variables">Variables collection.</param> /// <returns>Function result.</returns> public override IElement EvaluateScalar(Complex Argument1, Complex Argument2, Variables Variables) { return(new ComplexNumber(StatMath.Γ(Argument1, Argument2))); }
/// <summary> /// Evaluates the function on two scalar arguments. /// </summary> /// <param name="Argument1">Function argument 1.</param> /// <param name="Argument2">Function argument 2.</param> /// <param name="Variables">Variables collection.</param> /// <returns>Function result.</returns> public override IElement EvaluateScalar(double Argument1, double Argument2, Variables Variables) { return(new DoubleNumber(StatMath.Γ(Argument1, Argument2))); }