MCPcopy Create free account
hub / github.com/Open-Quant/openquant / sample_log_uniform

Function sample_log_uniform

crates/openquant/src/hyperparameter_tuning.rs:77–92  ·  view source on GitHub ↗
(
    low: f64,
    high: f64,
    rng: &mut R,
)

Source from the content-addressed store, hash-verified

75}
76
77pub 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
94pub fn classification_score(
95 y_true: &[f64],

Calls

no outgoing calls