
Assigning probability
Hi all,
I am about to design a class for a project that I am doing, however I cannot work out how to approach the design.
Basically I have a series of events that can occur, which I will probably store in an a vector as "descriptive" strings. But I want to be able to assign a probability (probably a percentage) of the events occurance.
For instance, you may have an array of weather descriptions, and during summer there is only a 5% chance of it raining on any given day.
Can anyone point me in the right direction?

You can generate random numbers in the range 0 to 100 easily enough.
Say event1 has a 25% probability of occuring, and event2 has a 75% probability.
Code:
//pseudocode
If randomnumber is between 0 and 25
event1
if randomnumber is between 26 and 100
event2
That wouldn't be horribly difficult to code into a class.

Mmm, that's so simple it could work!
Thanks. :)

Code:
//pseudocode
If randomnumber is between 0 and 25
event1
if randomnumber is between 26 and 100
event2
That's assuming the events are not independant. Otherwise it would look like this:
Code:
//pseudocode
If randomnumber is between 0 and 25
event1
if randomnumber2 is between 0 and 75
event2