| ... | @@ -65,7 +65,7 @@ pub const ZigTable = struct { | ... | @@ -65,7 +65,7 @@ pub const ZigTable = struct { |
| 65 | }; | 65 | }; |
| 66 | | 66 | |
| 67 | // zigNorInit | 67 | // zigNorInit |
| 68 | fn ZigTableGen( | 68 | pub fn ZigTableGen( |
| 69 | comptime is_symmetric: bool, | 69 | comptime is_symmetric: bool, |
| 70 | comptime r: f64, | 70 | comptime r: f64, |
| 71 | comptime v: f64, | 71 | comptime v: f64, |
| ... | @@ -102,16 +102,16 @@ pub const NormDist = blk: { | ... | @@ -102,16 +102,16 @@ pub const NormDist = blk: { |
| 102 | break :blk ZigTableGen(true, norm_r, norm_v, norm_f, norm_f_inv, norm_zero_case); | 102 | break :blk ZigTableGen(true, norm_r, norm_v, norm_f, norm_f_inv, norm_zero_case); |
| 103 | }; | 103 | }; |
| 104 | | 104 | |
| 105 | const norm_r = 3.6541528853610088; | 105 | pub const norm_r = 3.6541528853610088; |
| 106 | const norm_v = 0.00492867323399; | 106 | pub const norm_v = 0.00492867323399; |
| 107 | | 107 | |
| 108 | fn norm_f(x: f64) f64 { | 108 | pub fn norm_f(x: f64) f64 { |
| 109 | return @exp(-x * x / 2.0); | 109 | return @exp(-x * x / 2.0); |
| 110 | } | 110 | } |
| 111 | fn norm_f_inv(y: f64) f64 { | 111 | pub fn norm_f_inv(y: f64) f64 { |
| 112 | return @sqrt(-2.0 * @log(y)); | 112 | return @sqrt(-2.0 * @log(y)); |
| 113 | } | 113 | } |
| 114 | fn norm_zero_case(random: Random, u: f64) f64 { | 114 | pub fn norm_zero_case(random: Random, u: f64) f64 { |
| 115 | var x: f64 = 1; | 115 | var x: f64 = 1; |
| 116 | var y: f64 = 0; | 116 | var y: f64 = 0; |
| 117 | | 117 | |
| ... | @@ -143,16 +143,16 @@ pub const ExpDist = blk: { | ... | @@ -143,16 +143,16 @@ pub const ExpDist = blk: { |
| 143 | break :blk ZigTableGen(false, exp_r, exp_v, exp_f, exp_f_inv, exp_zero_case); | 143 | break :blk ZigTableGen(false, exp_r, exp_v, exp_f, exp_f_inv, exp_zero_case); |
| 144 | }; | 144 | }; |
| 145 | | 145 | |
| 146 | const exp_r = 7.69711747013104972; | 146 | pub const exp_r = 7.69711747013104972; |
| 147 | const exp_v = 0.0039496598225815571993; | 147 | pub const exp_v = 0.0039496598225815571993; |
| 148 | | 148 | |
| 149 | fn exp_f(x: f64) f64 { | 149 | pub fn exp_f(x: f64) f64 { |
| 150 | return @exp(-x); | 150 | return @exp(-x); |
| 151 | } | 151 | } |
| 152 | fn exp_f_inv(y: f64) f64 { | 152 | pub fn exp_f_inv(y: f64) f64 { |
| 153 | return -@log(y); | 153 | return -@log(y); |
| 154 | } | 154 | } |
| 155 | fn exp_zero_case(random: Random, _: f64) f64 { | 155 | pub fn exp_zero_case(random: Random, _: f64) f64 { |
| 156 | return exp_r - @log(random.float(f64)); | 156 | return exp_r - @log(random.float(f64)); |
| 157 | } | 157 | } |
| 158 | | 158 | |