I've got a fixed solution space defined by a minimum and maximum float which has no divisible slice.

You then have 0..N Gaussian distribution probability sets which I need to combine.

In the end I neeed

  1. Method to define probability set with a numeric range (not sliceable) and 0..N Gaussian functions
  2. A function which can generate a random number in the range as defined by the calculated probabilities.

Also I know it is possible that some combinations will generate a zero solution space.

Now I'm thinking the way to do it is take the normalised probability density functions and multiply them to get a new space then normalising the result. I just can't seem to break it down into algorithmic form.

Any ideas?

  • 1
    \$\begingroup\$ You would probably be better off asking this at math.stackexchange.com? \$\endgroup\$
    – bummzack
    Commented Aug 15, 2010 at 10:59
  • \$\begingroup\$ I thought about that, but I'm mostly concerned with how to do it algorithmically. A pure maths solution would help but not be the answer. \$\endgroup\$
    – Kimau
    Commented Aug 15, 2010 at 11:05
  • \$\begingroup\$ Then maybe try stackoverflow.com? It looks like a generic programming problem, I don't see the word "game" in your post anywhere (not that it's a requirement but that's a pretty good sign that you might want to look elsewhere) \$\endgroup\$
    – Ricket
    Commented Aug 15, 2010 at 15:41
  • \$\begingroup\$ I need help with some terms, like no divible slice, zero solution space, normalized probility density. \$\endgroup\$ Commented Aug 15, 2010 at 16:20
  • 1
    \$\begingroup\$ Hmm. the top hit for "divisible slice" on google is this question. Then a number of documents where "divisible" and "slice" occur next to each other, but are part of different sentences. You might want to explain that one, as it's obviously not uniform usage. \$\endgroup\$
    – drxzcl
    Commented Aug 16, 2010 at 7:45

1 Answer 1


First let's make sure I understood your question correctly:

  • You have a probability function that is expressed as a sum of N parametrized one-dimensional gaussians, each with different mean and standard deviation.
  • You want to generate stochastic variables according to this distribution.

Is this correct?

If this is the case, I reccommend you use a variation of rejection sampling. The recipe is quite straightforward, but you might have to iterate a bit before you get an answer out of it. This is the basic outline.

  1. You generate a uniformly distributed random number in your desired interval, x.
  2. You calculate the value of your probability distribution, p(x)
  3. You generate another uniformly distributed random number between 0 and 1, q
  4. If q < p(x), return x
  5. If not, start from step 1.

No matter how large the temptation, do not re-use q for different iterations.

  • \$\begingroup\$ I cannot use this method because as I stated a floating range is non-divisible (not sliceable). So sampling is impossible. I already use this method for enumerations which are possible to sample. Also I've taken advice and moved this question to Math Stack math.stackexchange.com/questions/2584/… \$\endgroup\$
    – Kimau
    Commented Aug 21, 2010 at 8:13
  • \$\begingroup\$ Ok, let's move there. \$\endgroup\$
    – drxzcl
    Commented Aug 21, 2010 at 15:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .