Jump to content
  • Advertisement
Sign in to follow this  
wasd

Probability calculation

This topic is 3319 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to calculate the amount of things that die from natural causes. At the moment, I've got this: For each thing, I do: if (Random number between 0 and 1) <= (Death probability) (Number to kill off) += 1 Which works fine and is exactly what I want, but I was wondering if there was a way to get the same kind of results with just a single calculation, e.g.: (Number to kill off) = (Random number) * (Death probability) * (Total number) The problem with the above is that it produces a lot lower numbers, and when there are a few things (between 1 and 100 say), you don't get any being killed off.

Share this post


Link to post
Share on other sites
Advertisement
The sum of discrete random variables can be approximated by a gaussian distribution with the same mean and variance. Assuming each entity has the same probability of dying P with a total number T, then the mean would be P * T and the variance would be (1 - P) * P * T. Plug those values into your favorite gaussian random number generator.

Share this post


Link to post
Share on other sites
What you are asking about is called binomial distribution.

A normal distribution is often a good approximation to the binomial distribution if you have enough events. If the probability of individual events is very small, a Poisson distribution is a better approximation.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!