aboutsummaryrefslogtreecommitdiff
path: root/Emby.Common.Implementations/TextEncoding/NLangDetect/Extensions/RandomExtensions.cs
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2017-08-18 02:04:21 -0400
committerGitHub <noreply@github.com>2017-08-18 02:04:21 -0400
commitc58db90c950c766321615eca236557d87b8d1b74 (patch)
tree80f1823f901bdadad6af4fce8d36d9b73f79c0fb /Emby.Common.Implementations/TextEncoding/NLangDetect/Extensions/RandomExtensions.cs
parentd5a9db3af77b06a355558165a984328e35555279 (diff)
parent883399caeba54da4c9f3e15e639f8fd72f5b559e (diff)
Merge pull request #2827 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Common.Implementations/TextEncoding/NLangDetect/Extensions/RandomExtensions.cs')
-rw-r--r--Emby.Common.Implementations/TextEncoding/NLangDetect/Extensions/RandomExtensions.cs51
1 files changed, 0 insertions, 51 deletions
diff --git a/Emby.Common.Implementations/TextEncoding/NLangDetect/Extensions/RandomExtensions.cs b/Emby.Common.Implementations/TextEncoding/NLangDetect/Extensions/RandomExtensions.cs
deleted file mode 100644
index d55ca80df..000000000
--- a/Emby.Common.Implementations/TextEncoding/NLangDetect/Extensions/RandomExtensions.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-
-namespace NLangDetect.Core.Extensions
-{
- public static class RandomExtensions
- {
- private const double _Epsilon = 2.22044604925031E-15;
-
- private static readonly object _mutex = new object();
-
- private static double _nextNextGaussian;
- private static bool _hasNextNextGaussian;
-
- /// <summary>
- /// Returns the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence.
- /// The general contract of nextGaussian is that one double value, chosen from (approximately) the usual normal distribution with mean 0.0 and standard deviation 1.0, is pseudorandomly generated and returned.
- /// </summary>
- /// <remarks>
- /// Taken from: http://download.oracle.com/javase/6/docs/api/java/util/Random.html (nextGaussian())
- /// </remarks>
- public static double NextGaussian(this Random random)
- {
- lock (_mutex)
- {
- if (_hasNextNextGaussian)
- {
- _hasNextNextGaussian = false;
-
- return _nextNextGaussian;
- }
-
- double v1, v2, s;
-
- do
- {
- v1 = 2.0 * random.NextDouble() - 1.0; // between -1.0 and 1.0
- v2 = 2.0 * random.NextDouble() - 1.0; // between -1.0 and 1.0
- s = v1 * v1 + v2 * v2;
- }
- while (s >= 1.0 || Math.Abs(s - 0.0) < _Epsilon);
-
- double multiplier = Math.Sqrt(-2.0 * Math.Log(s) / s);
-
- _nextNextGaussian = v2 * multiplier;
- _hasNextNextGaussian = true;
-
- return v1 * multiplier;
- }
- }
- }
-}