First, set the data and prepare the conditional distribution.
pxy
is joint distribution of Random Variable x
andy
.
py
is marginal distribution for variable y
of pxy
pcxy
is conditional distribution(distribution when x==0)
data = RandomFunction[WienerProcess[0, 1], {0, 1, 0.01}, 1000];
data // Normal // #[[All, 2]] & /@ # & // Set[sample, #] &;
Table[Transpose@{sample[[All, i]], sample[[All, i + 1]]}, {i, 1,
99}] // Flatten[#, 1] & // KernelMixtureDistribution //
Set[pxy, #] &;
px = MarginalDistribution[pxy, 1];
pcxy = PDF[pxy, {0, y}]/PDF[px, 0];
What I want to do is sampling from pcxy
quickly,or fast as long as possible.
Plot[pcxy, {y, -1, 1}]
What I've tried is the following(this didn't end at all):
ProbabilityDistribution[pcxy, {y, -Infinity, Infinity}]
RandomVariate[%, 3] // AbsoluteTiming