Skip to main content

unit_boundary_proportion

Function unit_boundary_proportion 

Source
pub fn unit_boundary_proportion(
    values: &[FloatType],
) -> Result<Vec<(FloatType, FloatType)>>
Expand description

The span of the unit interval each value’s share of their sum takes, one after another, the last ending at exactly one: music21’s unitBoundaryProportion.

use music21::common::numbertools::unit_boundary_proportion;

assert_eq!(
    unit_boundary_proportion(&[1.0, 1.0, 2.0])?,
    [(0.0, 0.25), (0.25, 0.5), (0.5, 1.0)]
);

§Errors

A negative value.