vendredi 23 mars 2018

Assign a random fraction to classes

I have

  • 5 classes A, B, C, D, E
  • a range from 0-100%

I want that a random fraction of my range is assigned to each of the classes, e.g.

A | 10%
B | 20%
C | 17% 
D | 33%
E | 20%
=========
  | 100%

or

A | 29%
B | 1%
C | 23% 
D | 17%
E | 30%
=========
  | 100%

I couldn't come up with a straight-forward way to do so. Any suggestions?




Aucun commentaire:

Enregistrer un commentaire