In: Statistics and Probability
Say I want to generate random variables from the probability distribution
p={ 2-2x 0<x<1
0 . elsewhere
My scheme is to generate U's from [0,1],double them and plug them into the probability distribution. So U = 0.3 gives me p(0.6)=0.8 as random variable. Prove my idea is right or wrong.
You are right except you forgot to subtract it from 2.
I generated 1000 x and calculated f(x)=2-2(x).
This is a sample from it.
X f(x)
0.107907 1.78419
0.403739 1.19252
0.427420 1.14516
0.909383 0.18123
0.050595 1.89881
0.132632 1.73474
0.215042 1.56992
0.901474 0.19705
0.347013 1.30597
0.573234 0.85353
0.051896 1.89621
0.889484 0.22103
0.829647 0.34071
0.548284 0.90343
0.774248 0.45150
0.589716 0.82057
0.799201 0.40160
Descriptive Statistics: X, f(x)
Total
Variable Count Mean StDev Median IQR
X 1000 0.48803 0.29540 0.49065 0.52513
f(x) 1000 1.0239 0.5908 1.0187 1.0503