lundi 12 avril 2021

Processing Weighted Probabilities

I'm pretty new to Processing (coming from R) and have been having trouble with a certain weighted probability function.

I have an array of 100 numbers.

The sum of all these numbers is then used to create an array with the length of the sum of the numbers.

Each number in the new array is initialised to zero.

What I trying to do:

  1. Go through each number in the first array (example, starting with the first number of the first array which, for example, will be 6).

  2. Set the first 6 (since that is the current number) items in the second array with the length sum to the index number of the 6. So, the first six items in the second array will be {0,0,0,0,0,0}.

  3. Repeat for all the numbers. Example, an array {6, 3, 1} should create the array {0,0,0,0,0,0,1,1,1,2}

Does anyone have any ideas how to accomplish this? I've tried a ton of solutions, but have never had to do weighted probabilities like this before. Thanks!




Aucun commentaire:

Enregistrer un commentaire