jeudi 21 mars 2019

representing distribution tables in c++ and random number generators

Ok so Im trying to write a simulation where a base ball player is at bat and im given a probability distribution table where the likelihood of getting a hit, out etc is listed in percentages here

im going to be using a while loop to simulate it at Bat 1000 times and use all those values to calculate the players batting percentage.

what i dont quite understand is how to represent the percentages and how to differentiate between the different types. Like i cant use an if(atBat<=5) to decide for homeruns because you have a 9 percent chance of getting a triple so doing if(atBat<=9) or doing an if(atBat>=5 && atBat<=9) cant work because your numeric probability is now 4 percent and not 9 percent. yall know what i mean or am i just overthinking this way too much.

Here's the prompt too.




Aucun commentaire:

Enregistrer un commentaire