From e98378f246c807c127b3e1d602191127c916f6b4 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Wed, 25 Oct 2023 15:21:16 +0200 Subject: [PATCH] Refactored ShapeFunction --- FastRng/Distributions/BetaA2B2.cs | 3 ++- FastRng/Distributions/BetaA2B5.cs | 3 ++- FastRng/Distributions/BetaA5B2.cs | 5 +++-- FastRng/Distributions/CauchyLorentzX0.cs | 3 ++- FastRng/Distributions/CauchyLorentzX1.cs | 3 ++- FastRng/Distributions/ChiSquareK1.cs | 3 ++- FastRng/Distributions/ChiSquareK10.cs | 3 ++- FastRng/Distributions/ChiSquareK4.cs | 3 ++- FastRng/Distributions/ExponentialLa10.cs | 3 ++- FastRng/Distributions/ExponentialLa5.cs | 3 ++- FastRng/Distributions/GammaA5B15.cs | 3 ++- FastRng/Distributions/InverseExponentialLa10.cs | 3 ++- FastRng/Distributions/InverseExponentialLa5.cs | 3 ++- FastRng/Distributions/InverseGammaA3B05.cs | 3 ++- FastRng/Distributions/LaplaceB01M0.cs | 3 ++- FastRng/Distributions/LaplaceB01M05.cs | 3 ++- FastRng/Distributions/LogNormalS1M0.cs | 3 ++- FastRng/Distributions/NormalS02M05.cs | 3 ++- FastRng/Distributions/StudentTNu1.cs | 3 ++- FastRng/Distributions/WeibullK05La1.cs | 3 ++- 20 files changed, 41 insertions(+), 21 deletions(-) diff --git a/FastRng/Distributions/BetaA2B2.cs b/FastRng/Distributions/BetaA2B2.cs index 81e9564..aeffa83 100644 --- a/FastRng/Distributions/BetaA2B2.cs +++ b/FastRng/Distributions/BetaA2B2.cs @@ -12,5 +12,6 @@ public sealed class BetaA2B2 : Distribution where TNum : IFloatingPo { } - private protected override TNum ShapeFunction(TNum x) => CONSTANT * TNum.Pow(x, ALPHA - TNum.One) * TNum.Pow(TNum.One - x, BETA - TNum.One); + /// + public override TNum ShapeFunction(TNum x) => CONSTANT * TNum.Pow(x, ALPHA - TNum.One) * TNum.Pow(TNum.One - x, BETA - TNum.One); } \ No newline at end of file diff --git a/FastRng/Distributions/BetaA2B5.cs b/FastRng/Distributions/BetaA2B5.cs index 77b7315..68d86aa 100644 --- a/FastRng/Distributions/BetaA2B5.cs +++ b/FastRng/Distributions/BetaA2B5.cs @@ -12,5 +12,6 @@ public sealed class BetaA2B5 : Distribution where TNum : IFloatingPo { } - private protected override TNum ShapeFunction(TNum x) => CONSTANT * TNum.Pow(x, ALPHA - TNum.One) * TNum.Pow(TNum.One - x, BETA - TNum.One); + /// + public override TNum ShapeFunction(TNum x) => CONSTANT * TNum.Pow(x, ALPHA - TNum.One) * TNum.Pow(TNum.One - x, BETA - TNum.One); } \ No newline at end of file diff --git a/FastRng/Distributions/BetaA5B2.cs b/FastRng/Distributions/BetaA5B2.cs index f9af4f1..e3f6b0b 100644 --- a/FastRng/Distributions/BetaA5B2.cs +++ b/FastRng/Distributions/BetaA5B2.cs @@ -11,6 +11,7 @@ public sealed class BetaA5B2 : Distribution where TNum : IFloatingPo public BetaA5B2(IRandom rng) : base(rng) { } - - private protected override TNum ShapeFunction(TNum x) => CONSTANT * TNum.Pow(x, ALPHA - TNum.One) * TNum.Pow(TNum.One - x, BETA - TNum.One); + + /// + public override TNum ShapeFunction(TNum x) => CONSTANT * TNum.Pow(x, ALPHA - TNum.One) * TNum.Pow(TNum.One - x, BETA - TNum.One); } \ No newline at end of file diff --git a/FastRng/Distributions/CauchyLorentzX0.cs b/FastRng/Distributions/CauchyLorentzX0.cs index 52fc302..ed729ec 100644 --- a/FastRng/Distributions/CauchyLorentzX0.cs +++ b/FastRng/Distributions/CauchyLorentzX0.cs @@ -13,5 +13,6 @@ public sealed class CauchyLorentzX0 : Distribution where TNum : IFlo { } - private protected override TNum ShapeFunction(TNum x) => CONSTANT * ( TNum.One / (TNum.Pi * SCALE)) * ((SCALE * SCALE) / (TNum.Pow(x - MEDIAN, TWO) + (SCALE * SCALE))); + /// + public override TNum ShapeFunction(TNum x) => CONSTANT * ( TNum.One / (TNum.Pi * SCALE)) * ((SCALE * SCALE) / (TNum.Pow(x - MEDIAN, TWO) + (SCALE * SCALE))); } \ No newline at end of file diff --git a/FastRng/Distributions/CauchyLorentzX1.cs b/FastRng/Distributions/CauchyLorentzX1.cs index bda6296..ef324dd 100644 --- a/FastRng/Distributions/CauchyLorentzX1.cs +++ b/FastRng/Distributions/CauchyLorentzX1.cs @@ -13,5 +13,6 @@ public sealed class CauchyLorentzX1 : Distribution where TNum : IFlo { } - private protected override TNum ShapeFunction(TNum x) => CONSTANT * (TNum.One / (TNum.Pi * SCALE)) * ((SCALE * SCALE) / (TNum.Pow(x - MEDIAN, TWO) + (SCALE * SCALE))); + /// + public override TNum ShapeFunction(TNum x) => CONSTANT * (TNum.One / (TNum.Pi * SCALE)) * ((SCALE * SCALE) / (TNum.Pow(x - MEDIAN, TWO) + (SCALE * SCALE))); } \ No newline at end of file diff --git a/FastRng/Distributions/ChiSquareK1.cs b/FastRng/Distributions/ChiSquareK1.cs index 8857f0e..9e27120 100644 --- a/FastRng/Distributions/ChiSquareK1.cs +++ b/FastRng/Distributions/ChiSquareK1.cs @@ -24,5 +24,6 @@ public sealed class ChiSquareK1 : Distribution where TNum : IFloatin { } - private protected override TNum ShapeFunction(TNum x) => CONSTANT * ((TNum.Pow(x, K_HALF_MINUS_ONE) * TNum.Exp(-x * HALF)) / DIVISOR); + /// + public override TNum ShapeFunction(TNum x) => CONSTANT * ((TNum.Pow(x, K_HALF_MINUS_ONE) * TNum.Exp(-x * HALF)) / DIVISOR); } \ No newline at end of file diff --git a/FastRng/Distributions/ChiSquareK10.cs b/FastRng/Distributions/ChiSquareK10.cs index 155ad9b..3c9156d 100644 --- a/FastRng/Distributions/ChiSquareK10.cs +++ b/FastRng/Distributions/ChiSquareK10.cs @@ -24,5 +24,6 @@ public sealed class ChiSquareK10 : Distribution where TNum : IFloati { } - private protected override TNum ShapeFunction(TNum x) => CONSTANT * ((TNum.Pow(x, K_HALF_MINUS_ONE) * TNum.Exp(-x * HALF)) / DIVISOR); + /// + public override TNum ShapeFunction(TNum x) => CONSTANT * ((TNum.Pow(x, K_HALF_MINUS_ONE) * TNum.Exp(-x * HALF)) / DIVISOR); } \ No newline at end of file diff --git a/FastRng/Distributions/ChiSquareK4.cs b/FastRng/Distributions/ChiSquareK4.cs index a514063..a7c86a9 100644 --- a/FastRng/Distributions/ChiSquareK4.cs +++ b/FastRng/Distributions/ChiSquareK4.cs @@ -24,5 +24,6 @@ public sealed class ChiSquareK4 : Distribution where TNum : IFloatin { } - private protected override TNum ShapeFunction(TNum x) => CONSTANT * ((TNum.Pow(x, K_HALF_MINUS_ONE) * TNum.Exp(-x * HALF)) / DIVISOR); + /// + public override TNum ShapeFunction(TNum x) => CONSTANT * ((TNum.Pow(x, K_HALF_MINUS_ONE) * TNum.Exp(-x * HALF)) / DIVISOR); } \ No newline at end of file diff --git a/FastRng/Distributions/ExponentialLa10.cs b/FastRng/Distributions/ExponentialLa10.cs index 8002bcc..a79a74e 100644 --- a/FastRng/Distributions/ExponentialLa10.cs +++ b/FastRng/Distributions/ExponentialLa10.cs @@ -11,5 +11,6 @@ public sealed class ExponentialLa10 : Distribution where TNum : IFlo { } - private protected override TNum ShapeFunction(TNum x) => CONSTANT * LAMBDA * TNum.Exp(-LAMBDA * x); + /// + public override TNum ShapeFunction(TNum x) => CONSTANT * LAMBDA * TNum.Exp(-LAMBDA * x); } \ No newline at end of file diff --git a/FastRng/Distributions/ExponentialLa5.cs b/FastRng/Distributions/ExponentialLa5.cs index c48eb2c..534286f 100644 --- a/FastRng/Distributions/ExponentialLa5.cs +++ b/FastRng/Distributions/ExponentialLa5.cs @@ -11,5 +11,6 @@ public sealed class ExponentialLa5 : Distribution where TNum : IFloa { } - private protected override TNum ShapeFunction(TNum x) => CONSTANT * LAMBDA * TNum.Exp(-LAMBDA * x); + /// + public override TNum ShapeFunction(TNum x) => CONSTANT * LAMBDA * TNum.Exp(-LAMBDA * x); } \ No newline at end of file diff --git a/FastRng/Distributions/GammaA5B15.cs b/FastRng/Distributions/GammaA5B15.cs index 1aa509e..1fb8654 100644 --- a/FastRng/Distributions/GammaA5B15.cs +++ b/FastRng/Distributions/GammaA5B15.cs @@ -21,5 +21,6 @@ public sealed class GammaA5B15 : Distribution where TNum : IFloating { } - private protected override TNum ShapeFunction(TNum x) => CONSTANT * ((BETA_TO_THE_ALPHA * TNum.Pow(x, ALPHA - TNum.One) * TNum.Exp(-BETA * x)) / GAMMA_ALPHA); + /// + public override TNum ShapeFunction(TNum x) => CONSTANT * ((BETA_TO_THE_ALPHA * TNum.Pow(x, ALPHA - TNum.One) * TNum.Exp(-BETA * x)) / GAMMA_ALPHA); } \ No newline at end of file diff --git a/FastRng/Distributions/InverseExponentialLa10.cs b/FastRng/Distributions/InverseExponentialLa10.cs index da6bc7d..de6b554 100644 --- a/FastRng/Distributions/InverseExponentialLa10.cs +++ b/FastRng/Distributions/InverseExponentialLa10.cs @@ -11,5 +11,6 @@ public sealed class InverseExponentialLa10 : Distribution where TNum { } - private protected override TNum ShapeFunction(TNum x) => CONSTANT * LAMBDA * TNum.Exp(LAMBDA * x); + /// + public override TNum ShapeFunction(TNum x) => CONSTANT * LAMBDA * TNum.Exp(LAMBDA * x); } \ No newline at end of file diff --git a/FastRng/Distributions/InverseExponentialLa5.cs b/FastRng/Distributions/InverseExponentialLa5.cs index 817beef..4db48be 100644 --- a/FastRng/Distributions/InverseExponentialLa5.cs +++ b/FastRng/Distributions/InverseExponentialLa5.cs @@ -11,5 +11,6 @@ public sealed class InverseExponentialLa5 : Distribution where TNum { } - private protected override TNum ShapeFunction(TNum x) => CONSTANT * LAMBDA * TNum.Exp(LAMBDA * x); + /// + public override TNum ShapeFunction(TNum x) => CONSTANT * LAMBDA * TNum.Exp(LAMBDA * x); } \ No newline at end of file diff --git a/FastRng/Distributions/InverseGammaA3B05.cs b/FastRng/Distributions/InverseGammaA3B05.cs index 56465da..0fa0047 100644 --- a/FastRng/Distributions/InverseGammaA3B05.cs +++ b/FastRng/Distributions/InverseGammaA3B05.cs @@ -22,5 +22,6 @@ public sealed class InverseGammaA3B05 : Distribution where TNum : IF { } - private protected override TNum ShapeFunction(TNum x) => FACTOR_LEFT * TNum.Pow(x, -ALPHA - TNum.One) * TNum.Exp(-BETA / x); + /// + public override TNum ShapeFunction(TNum x) => FACTOR_LEFT * TNum.Pow(x, -ALPHA - TNum.One) * TNum.Exp(-BETA / x); } \ No newline at end of file diff --git a/FastRng/Distributions/LaplaceB01M0.cs b/FastRng/Distributions/LaplaceB01M0.cs index 8e5dca7..2a74df1 100644 --- a/FastRng/Distributions/LaplaceB01M0.cs +++ b/FastRng/Distributions/LaplaceB01M0.cs @@ -20,5 +20,6 @@ public sealed class LaplaceB01M0 : Distribution where TNum : IFloati { } - private protected override TNum ShapeFunction(TNum x) => FACTOR_LEFT * TNum.Exp(-TNum.Abs(x - MU) / B); + /// + public override TNum ShapeFunction(TNum x) => FACTOR_LEFT * TNum.Exp(-TNum.Abs(x - MU) / B); } \ No newline at end of file diff --git a/FastRng/Distributions/LaplaceB01M05.cs b/FastRng/Distributions/LaplaceB01M05.cs index 5849316..de7a7e0 100644 --- a/FastRng/Distributions/LaplaceB01M05.cs +++ b/FastRng/Distributions/LaplaceB01M05.cs @@ -20,5 +20,6 @@ public sealed class LaplaceB01M05 : Distribution where TNum : IFloat { } - private protected override TNum ShapeFunction(TNum x) => FACTOR_LEFT * TNum.Exp(-TNum.Abs(x - MU) / B); + /// + public override TNum ShapeFunction(TNum x) => FACTOR_LEFT * TNum.Exp(-TNum.Abs(x - MU) / B); } \ No newline at end of file diff --git a/FastRng/Distributions/LogNormalS1M0.cs b/FastRng/Distributions/LogNormalS1M0.cs index 1900ad4..2f5ddd1 100644 --- a/FastRng/Distributions/LogNormalS1M0.cs +++ b/FastRng/Distributions/LogNormalS1M0.cs @@ -20,5 +20,6 @@ public sealed class LogNormalS1M0 : Distribution where TNum : IFloat { } - private protected override TNum ShapeFunction(TNum x) => (CONSTANT / (x * FACTOR)) * TNum.Exp( -(TNum.Pow(TNum.Log(x) - MU, TWO) / (TWO * TNum.Pow(SIGMA, TWO)))); + /// + public override TNum ShapeFunction(TNum x) => (CONSTANT / (x * FACTOR)) * TNum.Exp( -(TNum.Pow(TNum.Log(x) - MU, TWO) / (TWO * TNum.Pow(SIGMA, TWO)))); } \ No newline at end of file diff --git a/FastRng/Distributions/NormalS02M05.cs b/FastRng/Distributions/NormalS02M05.cs index 93cf3c3..340c7da 100644 --- a/FastRng/Distributions/NormalS02M05.cs +++ b/FastRng/Distributions/NormalS02M05.cs @@ -14,5 +14,6 @@ public sealed class NormalS02M05 : Distribution where TNum : IFloati { } - private protected override TNum ShapeFunction(TNum x) => TNum.One / (STD_DEV * SQRT_2_PI) * TNum.Exp(NEGATIVE_HALF * TNum.Pow((x - MEAN) / STD_DEV, TWO)); + /// + public override TNum ShapeFunction(TNum x) => TNum.One / (STD_DEV * SQRT_2_PI) * TNum.Exp(NEGATIVE_HALF * TNum.Pow((x - MEAN) / STD_DEV, TWO)); } \ No newline at end of file diff --git a/FastRng/Distributions/StudentTNu1.cs b/FastRng/Distributions/StudentTNu1.cs index b9706ae..3956521 100644 --- a/FastRng/Distributions/StudentTNu1.cs +++ b/FastRng/Distributions/StudentTNu1.cs @@ -26,5 +26,6 @@ public sealed class StudentTNu1 : Distribution where TNum : IFloatin { } - private protected override TNum ShapeFunction(TNum x) => CONSTANT * TNum.Pow((DIVIDEND / DIVISOR) * TNum.Pow( TNum.One + TNum.Pow(START + x * COMPRESS, TWO) / NU, EXPONENT), COMPRESS); + /// + public override TNum ShapeFunction(TNum x) => CONSTANT * TNum.Pow((DIVIDEND / DIVISOR) * TNum.Pow( TNum.One + TNum.Pow(START + x * COMPRESS, TWO) / NU, EXPONENT), COMPRESS); } \ No newline at end of file diff --git a/FastRng/Distributions/WeibullK05La1.cs b/FastRng/Distributions/WeibullK05La1.cs index 598bf8a..dcffec1 100644 --- a/FastRng/Distributions/WeibullK05La1.cs +++ b/FastRng/Distributions/WeibullK05La1.cs @@ -12,5 +12,6 @@ public sealed class WeibullK05La1 : Distribution where TNum : IFloat { } - private protected override TNum ShapeFunction(TNum x) => CONSTANT * ( (K / LAMBDA) * TNum.Pow(x / LAMBDA, K - TNum.One) * TNum.Exp(-TNum.Pow(x/LAMBDA, K))); + /// + public override TNum ShapeFunction(TNum x) => CONSTANT * ( (K / LAMBDA) * TNum.Pow(x / LAMBDA, K - TNum.One) * TNum.Exp(-TNum.Pow(x/LAMBDA, K))); } \ No newline at end of file -- 2.43.0