partitionWithCurve¶
- maelzel.distribute.partitionWithCurve(x, numpart, curve, method='brentq')[source]¶
Partition x in numparts parts following curve
- Parameters:
x (
float
) – the value to partitionnumpart (
int
) – the number of partitionscurve (
BpfInterface
) – the curve to follow. It is not important over which interval x it is defined. The y coord defines the width of the partition (see example)excluded – any value
- Return type:
list
[float
]- Returns:
the list of the partitions
Example
Partition the value 45 into 7 partitions following the given curve
>>> import bpf4 >>> curve = bpf4.halfcos(0, 11, 1, 0.5, exp=0.5) >>> distr = partitionWithCurve(45, 7, curve) >>> distr array([ 11. , 10.98316635, 10.4796218 , 7.89530421, 3.37336152, 0.76854613, 0.5 ]) >>> abs(sum(distr) - 45) < 0.001 True