Skip to main content
gamedev.net
🔒 Locked

Multimodal random sampling

Started by spraff Feb 24, 2009 at 8:21 AM 7 replies 1.2k views
Original Post
spraff
spraff
My random number library returns random gaussian(mu,sigmasq) as a floating-point number. No suprises there. I want to sample from several normal distributions at once, i.e. my probability density function is (1/n)*sum_{i=1}^{n}gaussian_i(mu_i,sigmasq_i) Is there an easy way to define a random number generator over this density in terms of the existing gaussian() function? Thanks in advance
Geometrian
Geometrian
Kind of looks like you've just done that...
[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]
spraff
spraff
No, what I've done is specify the output. I still don't see how to generate output of the given form
Brother Bob
Brother Bob
The sum of Gaussian random processes is a Gaussian random process whose expected value is the sum of the individual expected values, and whose variance is the sum of the individual variances. From there, you can figure out the resulting Gaussian process.
Lord Crc
Lord Crc
If you have the CDF, you can then evaluate it using a uniform random variable to get a random number distributed according to the PDF.

A brute-force approach would be to discretely sample the PDF, and generate a discrete CDF based on this. When evaluating/sampling the CDF, locate the closest samples and linearly interpolate between them. Since the CDF is monotonic you could use a binary search to locate the appropriate samples.

There may very well be more clever ways though :)
alvaro
alvaro
Brother Bob must not have noticed that you specified the density function as a sum of Gaussians, which is not the same thing as adding Gaussians (by convolution). To be fair, your post uses the notation `gaussian(mu,sigmasq)' to denote both the random variable and its density function, which is confusing.

To answer your question, pick a random integer k between 1 and n uniformly, then pick from gaussian(mu_k,sigmasq_k).
Brother Bob
Brother Bob
Quote:
Original post by alvaro
Brother Bob must not have noticed that you specified the density function as a sum of Gaussians, which is not the same thing as adding Gaussians (by convolution). To be fair, your post uses the notation `gaussian(mu,sigmasq)' to denote both the random variable and its density function, which is confusing.

You're right, I did miss that detail. And yes, that notation was confusing, took me some reads to actually get that correct now that you pointed it out.
spraff
spraff
Quote:
Original post by alvaro
Brother Bob must not have noticed that you specified the density function as a sum of Gaussians, which is not the same thing as adding Gaussians (by convolution). To be fair, your post uses the notation `gaussian(mu,sigmasq)' to denote both the random variable and its density function, which is confusing.

To answer your question, pick a random integer k between 1 and n uniformly, then pick from gaussian(mu_k,sigmasq_k).


Apologies for being unclear.

@alvaro That's a seductive answer, but I'm at a loss to justify it. Is there a standard result to this effect?
alvaro
alvaro
Quote:
Original post by spraff
@alvaro That's a seductive answer, but I'm at a loss to justify it. Is there a standard result to this effect?

Try to compute the density function of what I propose, and you'll see that it matches.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.