LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File basho_stats-1.0.4-rand.patch of Package basho_stats (Project home:Ledest:erlang:19)

diff -Ndurp basho_stats-1.0.4/rebar.config basho_stats-1.0.4-rand/rebar.config
--- basho_stats-1.0.4/rebar.config	2016-10-11 01:52:52.000000000 +0300
+++ basho_stats-1.0.4-rand/rebar.config	2017-08-13 17:50:13.904799766 +0300
@@ -1,5 +1,4 @@
 {deps, [
-    {rand_compat, "1.1", {git, "https://github.com/basho/erlang-rand-compat.git", {tag, "v1.1"}}}
 ]}.
 
 {cover_enabled, true}.
diff -Ndurp basho_stats-1.0.4/src/basho_stats_rv.erl basho_stats-1.0.4-rand/src/basho_stats_rv.erl
--- basho_stats-1.0.4/src/basho_stats_rv.erl	2016-10-11 01:52:52.000000000 +0300
+++ basho_stats-1.0.4-rand/src/basho_stats_rv.erl	2017-08-13 17:49:58.181157911 +0300
@@ -26,12 +26,6 @@
          poisson/1,
          normal/2]).
 
--on_load(init/0).
-
-init() ->
-    rand_compat:init(),
-    ok.
-
 %% ====================================================================
 %% Public API
 %% ====================================================================
@@ -40,13 +34,13 @@ init() ->
 %% Generates a uniformly-distributed random variable (wrapper for convenience)
 %%
 uniform() ->
-    rnd:uniform().
+    rand:uniform().
 
 %%
 %% Generates an exponential-distributed random variable, using inverse function
 %%
 exponential(Lambda) ->
-    -math:log(rnd:uniform()) / Lambda.
+    -math:log(rand:uniform()) / Lambda.
 
 %%
 %% Generates a Poisson-distributed random variable by summing exponential rvs
@@ -59,8 +53,8 @@ poisson(Lambda) ->
 %% Generates a Normal-distributed random variable, using Box-Muller method
 %%
 normal(Mean, Sigma) ->
-    Rv1 = rnd:uniform(),
-    Rv2 = rnd:uniform(),
+    Rv1 = rand:uniform(),
+    Rv2 = rand:uniform(),
     Rho = math:sqrt(-2 * math:log(1-Rv2)),
     Rho * math:cos(2 * math:pi() * Rv1) * Sigma + Mean.
 
@@ -70,6 +64,6 @@ normal(Mean, Sigma) ->
 %% ====================================================================
 
 poisson_rv_loop(Lambda, Sum, N) when Sum < Lambda ->
-    poisson_rv_loop(Lambda, Sum - math:log(rnd:uniform()), N+1);
+    poisson_rv_loop(Lambda, Sum - math:log(rand:uniform()), N+1);
 poisson_rv_loop(_Lambda, _Sum, N) ->
     N.