Question: Endless computation for a sample from a created distribution function

Hi all,

 

I want to create a (set of) samples from an own distribution. The distribution itself is a normal distribution, but with some 'gaps', as shown below:

plot(exp(-(t-10)^2/(2*(0.5e-1*10)^2))*piecewise(t<9,0,t<9.9,1, t<10.1,0, t<11,1), t = 8.5 .. 11.5)

(It is supposed to represent the distribution of discrete resistor values (e.g. 10 ohms), where not only the values above the tolerance (e.g. 10%) are removed, but also those who can be sold as higher precision resistors (eg. 1%). The mean, lower tolerance and higher tolerance should be variables).

Because of the fact that in order to be able to use the Sample function, the PDF should be twice differentiable, the 'truncation' in the middle is realised using logistic functions.

I am able to create said distribution, and produce a DensityPlot, but when I try to take a (even a single) Sample from a RandomVariable from that distribution, Maple keeps calculating and no sample is produced.

GetDist := (mu, alpha, beta) -> Distribution(PDF = unapply(LotRPDF(t, mu, alpha, beta), t)):
T := GetDist(10, .1, 0.1e-1);
DensityPlot(T);
RandomR := RandomVariable(T):
Sample(RandomR, 1);

Where LotRPDF is the function depicted above, mu is the mean (10), alpha is the maximum tolerance (10%), , beta is the minimum tolerance (1%)

Am i overlooking something simple? Or is there a more fundamental error in my approach? I've added the maple sheet with more details.

RandomVariableSample.mw

 

Please Wait...