Dear Community,
I would like to ask your help again.
Related to the problem above, I would like to define the PDF and CDF of the following events:
X1 and X2 are random variable from normal distributions with equal sigma and mu1 <= mu2.
What is the conditional distribution of X1 when X1>X2?
As I have programming background, I've made a simulation in R:
mu1 <- 0
mu2 <- 3
r.u1 <- rnorm(n = 10000000, mean = mu1, sd = sigma)
r.u2 <- rnorm(n = 10000000, mean = mu2, sd = sigma)
RS2.u1 <- dnorm(xx, mean = mu1, sd = s1)
RS3.u2 <- dnorm(xx, mean = mu2, sd = s2)
tt <- as.data.frame(cbind(r.u1, r.u2, collision = r.u1 > r.u2))
hh <- hist(tt[tt$collision == 1,"r.u2"], freq = F, breaks = xx, xlim = c(-10, 10))
![enter image description here][1]
To figure out the CDF first in Mathematica, my attempt was:
distX = (1/Sqrt[2 Pi \[Sigma]1^2]) Exp[-((x - \[Mu]1)/\[Sigma]1)^2/2]
distY = (1/Sqrt[2 Pi \[Sigma]1^2]) Exp[-((y - \[Mu]1)/\[Sigma]1)^2/2]
distXminusY =
Assuming[\[Sigma] > 0,
TransformedDistribution[
x - y, {x \[Distributed] NormalDistribution[\[Mu]1, \[Sigma]],
y \[Distributed] NormalDistribution[\[Mu]2, \[Sigma]]}]]
dist_condyx =
Assuming[Element[{\[Mu]1, \[Mu]2, \[Sigma]1}, Reals] && \[Sigma]1 >
0 , Integrate[
distX[t]*(1 - CDF[distY, t])/CDF[distXminusY, 0], {t, -Infinity,
x}]]
It seems it can't integrate the function but maybe I define it incorrectly. To get the PDF I have to derivate this function afterwards.
Can you advise me how to proceed with this?
Many thanks for your help.
Best,
Attila
Attachments: