Microsoft
Software
Hardware
Network
Question : Calculating Probability using C#
Hello,
I'm wondering how to approach a problem of calculating probability in C#.
Lets say, we know that some task has a 5% probability of happening and there're say 100 identical tasks. So theoretically, 5 tasks should happen, but as those tasks are individual tasks, each task has a 5% probability of happening. So, how can I simulate this case using programming?
I presume that I can get 5 random number using Random class (Random rand = new Random(); rand.Next(1, 100)), and then get another 100 numbers and see if any number is in the set I generated first. But in this case, it's not truly random as generating first 5 numbers can use all "random potential" of these numbers and they will happened to be generated again.
Is there any accurate way of doing it?
Thanks
Answer : Calculating Probability using C#
Well, I'm not a probability expert myself. But since the random generator is uniformly distributed, so there would be equal chance of you getting 50 as you getting 99. In effect that gives a task a 5% probability of getting happening.
Random Solutions
Entourage 2008 users can no longer login/sync to Exchange 2007
Return Multiple Rows as Delimited List
How to access CD-ROM/Audio of Thin Client Device after login to Microsoft Terminal Server?
Run-Time Error 3155 ODBC-Time Out on a linked table.
ORDER BY in UNION query that contains both text and numbers
How can I put the file name and a SHORT path at the bottom of my word 2007 documents?
How can I programmatically get a list of spreadsheets from a MS Excel workbook?
DC not responding to directory service requests
How do I return multiple files in Excel VBA using GetOpenFilename?
SCRIPT to reboot WINDOWS 2008 server with scheduled task