I am having a lot of trouble trying to graph this function in matlab and trying to get it to look like it should. I need to generate 200 random samples of a uniform random variable X on the range (0,1) and transforming by the formula $Y=X^2$. Then normalize it so the area is 1.
So I transformed $f(x) = \frac{1}{1-0}=1$ by the equation $f(y) = f(x) * \left |\frac{dx}{dy} \right |$ to get $f(y)=\frac{1}{2x}=\frac{1}{2\sqrt{y}}$ on the range from 0 to 1
Matlab Code:
x = rand(200,1)
histplot = zeros(200,1)
for j = 1:200
histplot(j) = 1/(2*x(j))
end
hist(histplot)
This results in the following graph:
https://dl.dropboxusercontent.com/u/20608771/untitled.jpg
Now there is something seriously wrong that i am missing, because I don't the graph should look somewhat like the following:
https://dl.dropboxusercontent.com/u/20608771/untitled2.jpg
How is my data so off from what it should look like?