(
low: f64,
high: f64,
rng: &mut R,
)
| 75 | } |
| 76 | |
| 77 | pub fn sample_log_uniform<R: Rng + ?Sized>( |
| 78 | low: f64, |
| 79 | high: f64, |
| 80 | rng: &mut R, |
| 81 | ) -> Result<f64, String> { |
| 82 | if low <= 0.0 || high <= 0.0 { |
| 83 | return Err("log-uniform bounds must be strictly positive".to_string()); |
| 84 | } |
| 85 | if low >= high { |
| 86 | return Err("log-uniform low must be < high".to_string()); |
| 87 | } |
| 88 | let log_low = low.ln(); |
| 89 | let log_high = high.ln(); |
| 90 | let draw = rng.gen_range(log_low..log_high); |
| 91 | Ok(draw.exp()) |
| 92 | } |
| 93 | |
| 94 | pub fn classification_score( |
| 95 | y_true: &[f64], |
no outgoing calls