Skip to main content

unit_normalize_proportion

Function unit_normalize_proportion 

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

Each value as its share of their sum: music21’s unitNormalizeProportion.

use music21::common::numbertools::unit_normalize_proportion;

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

§Errors

A negative value. Values summing to nought give no finite shares.