🔒 Locked
Multimodal random sampling
Advertisement
Original Post
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
Kind of looks like you've just done that...
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.
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 :)
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 :)
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).
To answer your question, pick a random integer k between 1 and n uniformly, then pick from gaussian(mu_k,sigmasq_k).
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.
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?
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement