DoxigAlpha

norm_zero_case

Function parameters

Parameters

#
u:f64

Type definitions in this namespace

Types

#

Functions in this namespace

Functions

#

= blk: { @setEvalBranchQuota(30000); break :blk ZigTableGen(true, norm_r, norm_v, norm_f, norm_f_inv, norm_zero_case); }

Values

#
NormDist
= blk: { @setEvalBranchQuota(30000); break :blk ZigTableGen(true, norm_r, norm_v, norm_f, norm_f_inv, norm_zero_case); }
norm_r
= 3.6541528853610088
norm_v
= 0.00492867323399
ExpDist
= blk: { @setEvalBranchQuota(30000); break :blk ZigTableGen(false, exp_r, exp_v, exp_f, exp_f_inv, exp_zero_case); }
exp_r
= 7.69711747013104972
exp_v
= 0.0039496598225815571993

Source

Implementation

#
pub fn norm_zero_case(random: Random, u: f64) f64 {
    var x: f64 = 1;
    var y: f64 = 0;

    while (-2.0 * y < x * x) {
        x = @log(random.float(f64)) / norm_r;
        y = @log(random.float(f64));
    }

    if (u < 0) {
        return x - norm_r;
    } else {
        return norm_r - x;
    }
}