Skip to main content

band

Function band 

pub fn band(dist: &Distribution, side: Side) -> Result<Band>
Expand description

The crowding band at side of dist — §8.5.

  • Continuous float (step: None): the outer 2% of the unit range, i.e. Band::Continuous with width = 0.02. pressure tests membership through Distribution::to_unit, so a logarithmic float’s band is 2% in the transformed coordinate, not 2% of the raw value: loguniform(1e-5, 1e-2) crowds near 1e-2 long before a value gets within 2% of it in absolute terms.
  • Discrete support (an Int, or a stepped Float): the outermost max(1, ceil(0.02 * cardinality)) grid points, i.e. Band::Discrete. int(1, 4) has cardinality 4, so its band is exactly one point — the value 4 on the high side, 1 on the low side. A fixed unit-coordinate epsilon would be meaningless here (int(1, 4)’s grid spacing is 1/3 in unit terms), which is why the discrete case counts grid points instead of dividing through a transform.

A categorical or boolean parameter has no order and therefore no bound to crowd — see Error::Unsupported below.

§side is part of the signature even though the answer is symmetric

Both branches above compute the same magnitude regardless of which side is asked about, so this function ignores side today and returns the same Band for Side::Low and Side::High alike. It is still a parameter because §8 spells band(dist, side), while the growth engine already treats the sides independently: §8.9 clamps only the low side of a linear range at zero, and §9.6’s limit can itself be one-sided. Keeping side in this measurement signature preserves that distinction for callers.

§Errors

use atune_core::space::{Band, Distribution, Side, band};

let lr = Distribution::float_log(1e-5, 1e-2).unwrap();
assert_eq!(band(&lr, Side::Low).unwrap(), Band::Continuous { width: 0.02 });
assert_eq!(
    band(&lr, Side::Low).unwrap(),
    band(&lr, Side::High).unwrap(),
    "symmetric today -- see the note above"
);

let batch = Distribution::int(1, 4).unwrap();
assert_eq!(band(&batch, Side::High).unwrap(), Band::Discrete { count: 1 });

assert!(band(&Distribution::boolean(), Side::Low).is_err());