/// Computes the NN bound derived from Cover&Hart, given
/// the error and the number of labels.
Computes the NN bound derived from Cover&Hart, given
the error and the number of labels.
Computes the NN bound derived from Cover&Hart given the error and the number of labels .
pub fn nn_bound(error: f64, nlabels: usize) -> f64 {
    let nl = nlabels as f64;
    // Computing: (L-1)/L * (1 - (1 - L/(L-1)*error).sqrt())
    // with error = min(error, rg).
    let rg = (nl - 1.) / nl;
    match error {
        e if e < rg => rg * (1. - (1. - nl / (nl - 1.) * error).sqrt()),
        _ => rg,
    }
}
pub fn nn_bound ( error : f64 , nlabels : usize ) -> f64 { let nl = nlabels as f64 ; // Computing: (L-1)/L * (1 - (1 - L/(L-1)*error).sqrt()) // with error = min(error, rg). let rg = ( nl - 1. ) / nl ; match error { e if e < rg => rg * ( 1. - ( 1. - nl / ( nl - 1. ) * error ) . sqrt ( ) ) , _ => rg , } }
Computes the NN bound derived from Cover&Hart, given
the error and the number of labels.
Computes the NN bound derived from Cover&Hart given the error and the number of labels .
error
f64
nlabels
usize