Random Sampling from a Singular PDF
Define a formula distribution by a probability density function. The density function is not continuous and contains an infinite singularity.
In[1]:=
dist = ProbabilityDistribution[
Piecewise[{{1/(4 Sqrt[Abs[x]]), -1 < x < 0}, {2/3, 1/4 < x <= 1}},
0], {x, -1, 1}]
Out[1]=
Generate a random sample from the distribution and compare its histogram with the density function.
In[2]:=
sample = RandomVariate[dist, 10^5];
show complete Wolfram Language input
Out[3]=