Skip to content

Commit

Permalink
Owl_base_stats_dist_gaussian.{std_gaussian_rvs,gaussian_rvs}: avoid i…
Browse files Browse the repository at this point in the history
…nfinity on Random.float returning 0

#661

Signed-off-by: Edwin Török <[email protected]>
  • Loading branch information
edwintorok committed Mar 16, 2024
1 parent 99ee1b3 commit fd8ec0f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/base/stats/owl_base_stats_dist_gaussian.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ let std_gaussian_rvs () =
!_z1)
else (
_case := true;
_u1 := Random.float 1.;
_u2 := Random.float 1.;
_u1 := rand01_exclusive ();
_u2 := rand01_exclusive ();
_z0 := sqrt (~-.2. *. log !_u1) *. cos (2. *. Owl_const.pi *. !_u2);
_z1 := sqrt (~-.2. *. log !_u1) *. sin (2. *. Owl_const.pi *. !_u2);
!_z0)
Expand All @@ -35,8 +35,8 @@ let gaussian_rvs ~mu ~sigma =
mu +. (sigma *. !_z1))
else (
_case := true;
_u1 := Random.float 1.;
_u2 := Random.float 1.;
_u1 := rand01_exclusive ();
_u2 := rand01_exclusive ();
_z0 := sqrt (~-.2. *. log !_u1) *. cos (2. *. Owl_const.pi *. !_u2);
_z1 := sqrt (~-.2. *. log !_u1) *. sin (2. *. Owl_const.pi *. !_u2);
mu +. (sigma *. !_z0))

0 comments on commit fd8ec0f

Please sign in to comment.