1

I'm experimenting with AI for an extremely simple simulation game. The game will contain people (instances of objects with random properties) who have a set amount of money to spend.

I'd like the distribution of "wealth" to be statistically valid. How can I generate a random number (money) which adheres to a standard deviation (e.g. mean:50, standard deviation: 10), whereby a value closer to the mean is more likely to be generated?

skypjack
  • 49,335
  • 19
  • 95
  • 187
M-R
  • 411
  • 2
  • 6
  • 15
  • What kind of distribution do you want? When I hear "standard deviation" I think normal distribution. Or do you want advice on what distribution to use? – usr Dec 18 '15 at 21:16

2 Answers2

4

I think you're focusing on the wrong end of the problem. The first thing you need to do is identify the distribution you want to use to model wealth. A normal distribution with a mean of 50 and standard deviation of 10 nominally meets your needs, but so does a uniform distribution in the range [32.67949, 67.32051]. There are lots of statistical distributions that can have the same mean and standard deviation but which have completely different shapes, and it is the shape that will determine the validity of your distribution.

Income and wealth turn out to have very skewed distributions - they are bounded below by zero, while a few people have such large amounts compared to the rest of us that they drag the mean upward by quite noticeable amounts. Consequently, you don't want to use a naive distribution choice such as uniform or Gaussian, or anything else that is symmetric or can dip into negative territory. Using an exponential would be far more realistic, but still may not be sufficiently extreme to capture actual wealth distribution we see in the real world.

Once you've picked a distribution, there are many software libraries or sources of info that will help you generate values from that distribution.

pjs
  • 18,696
  • 4
  • 27
  • 56
0

Generating random numbers is a vast topic. But since you said it's a simple simulation, here's a simple approach to get going:

Generate several (say n) random numbers uniformly distributed on (0, 1). The built-in function Math.random can supply those numbers.

Add up those numbers. The sum has a distribution which is approximately normal, with mean = n/2 and standard deviation = sqrt(n)/sqrt(12). So if you subtract n/2, and then divide by sqrt(n)/sqrt(12), you'll have something which is approximately normal with mean 0 and standard deviation 1. Obviously if you pick n = 12 all you have to do is subtract 6 from the sum and you're done.

Now to get any other mean and standard deviation, just multiply by the standard deviation you want, and add the mean you want.

There are many other ways to go about it, but this is perhaps the simplest. I assume that's OK given your description of the problem.

Robert Dodier
  • 16,905
  • 2
  • 31
  • 48
  • That's a really bad way to generate approximately normal values. Why would OP want to do that when 1) there are far better methods to get normals (Java already provides `Random.nextGaussian()`), and 2) normals are a terrible distribution to use for wealth or income? – pjs Dec 19 '15 at 00:04
  • Because it's simple. – Robert Dodier Dec 19 '15 at 00:18
  • Simpler would be to just use `Random.nextGaussian()`. – pjs Dec 19 '15 at 00:24