Browse Source

Distributions: make more properties available on the type (instead of explicit interface impl)

pull/729/head
Christoph Ruegg 6 years ago
parent
commit
36c5ee21e1
  1. 16
      src/Numerics/Distributions/BetaBinomial.cs
  2. 8
      src/Numerics/SpecialFunctions/GeneralizedHyperGeometric.cs

16
src/Numerics/Distributions/BetaBinomial.cs

@ -3,7 +3,7 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
//
// Copyright (c) 2009-2014 Math.NET
// Copyright (c) 2009-2020 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@ -141,17 +141,17 @@ namespace MathNet.Numerics.Distributions
/// <summary>
/// Gets the mean of the distribution.
/// </summary>
double IUnivariateDistribution.Mean => (_n * _a) / (_a + _b);
public double Mean => (_n * _a) / (_a + _b);
/// <summary>
/// Gets the variance of the distribution.
/// </summary>
double IUnivariateDistribution.Variance => (_n*_a*_b*(_a+_b+_n))/(Math.Pow((_a+_b),2) * (_a+_b+1));
public double Variance => (_n*_a*_b*(_a+_b+_n))/(Math.Pow((_a+_b),2) * (_a+_b+1));
/// <summary>
/// Gets the standard deviation of the distribution.
/// </summary>
double IUnivariateDistribution.StdDev => Math.Sqrt((_n * _a * _b * (_a + _b + _n)) / (Math.Pow((_a + _b), 2) * (_a + _b + 1)));
public double StdDev => Math.Sqrt((_n * _a * _b * (_a + _b + _n)) / (Math.Pow((_a + _b), 2) * (_a + _b + 1)));
/// <summary>
/// Gets the entropy of the distribution.
@ -161,14 +161,14 @@ namespace MathNet.Numerics.Distributions
/// <summary>
/// Gets the skewness of the distribution.
/// </summary>
double IUnivariateDistribution.Skewness =>
public double Skewness =>
(_a + _b + 2 * _n) * (_b - _a) / (_a + _b + 2) * Math.Sqrt((1 + _a + _b) / (_n * _a * _b * (_n + _a + _b)));
/// <summary>
/// Gets the mode of the distribution
/// </summary>
int IDiscreteDistribution.Mode => throw new NotSupportedException();
/// <summary>
/// Gets the median of the distribution.
/// </summary>
@ -235,7 +235,7 @@ namespace MathNet.Numerics.Distributions
}
else
{
return Math.Exp(PMFLn(n, a, b, k));
return Math.Exp(PMFLn(n, a, b, k));
}
}
@ -330,7 +330,7 @@ namespace MathNet.Numerics.Distributions
/// <summary>
/// Fills an array with samples generated from the distribution.
/// </summary>
public void Samples(int[] values)
public void Samples(int[] values)
{
SamplesUnchecked(_random, values, _n, _a, _b);
}

8
src/Numerics/SpecialFunctions/GeneralizedHyperGeometric.cs

@ -3,7 +3,7 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
//
// Copyright (c) 2009-2010 Math.NET
// Copyright (c) 2009-2020 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@ -38,16 +38,13 @@ namespace MathNet.Numerics
{
public static partial class SpecialFunctions
{
//Rising and falling factorials - reference here:
//https://en.wikipedia.org/wiki/Falling_and_rising_factorials
/// <summary>
/// Computes the Rising Factorial (Pochhammer function) x -> (x)n, n>= 0. see: https://en.wikipedia.org/wiki/Falling_and_rising_factorials
/// </summary>
/// <returns>The real value of the Rising Factorial for x and n</returns>
public static double RisingFactorial(double x, int n)
{
double accumulator = 1.0;
@ -73,7 +70,6 @@ namespace MathNet.Numerics
}
return accumulator;
}
//
/// <summary>
/// A generalized hypergeometric series is a power series in which the ratio of successive coefficients indexed by n is a rational function of n.
@ -137,7 +133,7 @@ namespace MathNet.Numerics
}
else
{
return incrementAs / incrementBs * Math.Pow(z, currentN) / Factorial(currentN);
return incrementAs / incrementBs * Math.Pow(z, currentN) / Factorial(currentN);
}
}

Loading…
Cancel
Save