Please forgive me if this question is incorrectly formulated or the solution is trivial. I can't seem to find an existing answer with conditions that I am familiar with.
I have an array of non-negative floats and I want to normalize them, which I can do. My problem: I would like the sum of all the elements in the collection to be a certain amount.
I can imagine ugly ways to achieve this, but I just know that there is a “right” way to do this. The goal is to create a composite histogram whose total width should be fixed. Each data point in the collection is assigned a color, which should receive N% of the total width of the bargraph. I am limited to this approach using the graph mapping method.
C # examples are preferred if code is needed.
var ratio = 100.0 / widths.Max();
var normalizedList = widths.Select(o => o * ratio).ToList();
My huge and sincere thanks for any help,
additional information: The
graph is a composite (segmented) histogram. Each element of the float collection corresponds to a segment. http://oi62.tinypic.com/2vskt8m.jpg
The necessity of the sum-of-all-elements-is-N rule relates to a graph drawing method, over which I have limited authority.
( , ), , , . , , , . , , .