| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Simulation - Composition method
Hi all, this question doesn't really have to do with C, but it is related to simulation, and without solving this first, I can't do the random variate generator.
I'm supposed to generate random variates for p(x) ~ pi - x + x^2 + sin(x), for 0 <= x <= pi. I got the normalization factor as 6 / (12 + 3*pi^2 + 2*pi^3), which gives me my f(x) as f(x) = [6 / (12 + 3*pi^2 + 2*pi^3)] * (pi - x + x^2 + sin(x)). I then run into problems decomposing the f(x). I decomposed it into the following equation: f(x) = 6*pi / a - (3*pi^2 / a) * f_1(x) + (2*pi^3 / a) * f_2(x) + (12 / a) * f_3(x) where a = (12 + 3*pi^2 + 2*pi^3), f_1(x) = 2x/pi^2, f_2(x) = 3x^2 / pi^3, f_3(x) = ½ sinx. I reasoned that f_1 is proportional to x, f_2 to x^2, and f_3 to sin(x). I then normalized f_1, f_2 and f_3, obtaining the respective individual distributions. However, I'm confused by the presence of the constant term 6*pi / a and the negative sign in front of f_1. What should I do with them? I'm really confused with the whole composition method, and I would greatly appreciate it if someone could point me to a website that gives a clear explanation of how to decompose the distributions. Thank you. Regards, Rayne |
|
#2
|
|||
|
|||
|
Hey! Just...a question for you: what are you trying to do? Maybe I don't understand your intentions quite well, but why do you create 3 functions from f(x) ?
Could you explain to me what normalization factor is (I'm not from an english speaking country...and as a consecuence, I may know that with a different name!). I'm quite good on simulation, I just don't know exactly what we're talking about here! See if I can help you later!! ANibal. PS: provide an example, if you have the time.... |
|
#3
|
|||
|
|||
|
I'm supposed to generate random variates for p(x) ~ pi - x + x^2 + sin(x) using the composition method. The normalization factor is a factor I found for p(x) such that p(x) is normalized, i.e. when you integrate the given p(x) from 0 to pi, you get the value 1, => F(x) = 1 from 0 <= x <= pi. My normalized p(x) turned out to be [6/(12 + 3pi^2 + 2pi^3)] * (pi - x + x^2 + sin(x)).
I was taught that "the composition technique is applied when the distribution function F (or f) can be expressed as a positive combination of other distribution functions F_1, F_2, ..., from which we can generate variates easily", i.e. f(x) = sum of (p_j * f_j(x)). That was why I tried to break up the p(x) into individual "terms". |
|
#4
|
|||
|
|||
|
Allright...now I see! F(x) is the acumulate probability function (that's how we know it here!). The question is: what are you really trying to generate: values for x or for the function itself?
If you want to generate values for the function itself, just give values to x between 0 and pi (easy thing to do). If you want to get values for x, that's a little harder to do. Since the F(x) has no inverse function (at least not easily found) I would use the rejection method, where lock the function inside a known area function and you generate a random point (x, y) and see if y <= F(x) (the point is inside the valid area), you accept x as the generated value (if not, just find another point). Unfortunatly, I've never used the composition method! I'm not sure if that's what you asked... Good Luck ANibal. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Simulation - Composition method |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|