Proof of ratio distribution normal and uniform

Join the discussion
Registration is free. Start your own thread to ask a follow-up.
34 replies · 8K views
That might be overkill: I'd try -100 to 100 first with say 0.1 increment and then increase it slowly to see if the both retain the same shape.

You know that if things are way off at the start that something is up.
 
Physics news on Phys.org
Code:
%Assigement with restricted values (1)

x=normrnd(0,1,1,150e4); %generate standard normal numbers
y=1+(1-0.5).*rand(1,150e4); %generate uniform numbers in interval [0,1]
z=x./y; %desired new variable
hist(z);

%Tryings to verify that the experssion meet with (1)in
%means of histogram

%for postivie values
t=rand(1,150e4);
t=1./t;
%negative values
t_neg=rand(1,150e4);
t=[-1./t_neg t];
%getting z by the exponenatial expression and plotting it's
%histogram
Z_exp=(1/sqrt(2*pi)).*((1-exp(-(t.^2)/2))./t.^2);
%%%%OR%%%%%%
% t=-1000:0.0001:1000;
% Z=(1/sqrt(2*pi)).*((1-exp(-(t.^2)./2))./t.^2);
figure()
hist(Z_exp);
%Using the formula from wikipedia Slash PDF
Z=normpdf(0,0,1)-normpdf(t,0,1);
Z=Z./t.^2;
figure()
hist(Z);

so i am trying to get the histogram that is like the histogram(bell shape) i am getting from the first section of the code.
and what i get is :

1. from the second section (with the exponent) it isn't looks so.
2. the third section it is like the second one exactly, but when I'm changing the command from "Z=normpdf(0,0,1)-normpdf(t,0,1);"
to
"Z=normcdf(0,0,1)-normcdf(t,0,1);"
i'm getting the bell shape with "heavy\thick" tails.

so my conclusion so far is:
the exponential expression that i derived with your help is exact(hist graph) to the third section when using "normpdf".
and the third section is a bell shape when i use "bell shape".
and my aim is to be able to get the bell shape from the second expression.(the exponential term)

*from Wikipedia
PDF: [itex]\frac{\Phi(0)-\Phi(t)}{t^{2}}[/itex]
 
wuid said:
and my aim is to be able to get the bell shape from the second expression.(the exponential term)
This is the MATLAB code I used to plot it. Notice that it scales the theoretical distribution by the number of samples per bin (of the histogram) so that the two graphs are equally scaled.

Code:
N=1e5				% Number of samples
rand('uniform')
y=rand(1,N);			% uniform distribution
rand('normal')
x=rand(1,N);			% standard normal distribution
z=x./y;
z(abs(z)>10) = [];		% Limit range
hist(z,101)			% 101 bin histogram covering span -10 to +10
t=[-10:0.02:10];		% parameter for theoretical distribution
t( abs(t)<1e-6 ) = [];		% avoid pesky NANs
N_bin=N*20/101;			% samples per bin of histogram
z1=N_bin/sqrt(2*pi)*(1-exp(-t.*t/2))./(t.*t);
hold				% hold histogram plot
plot(t,z1,'g')			% and overlay theoretical distribution
 
WOW fantastic , thank's
i will check it more carefully to understand it.
 
uart said:
Yeah, I did it a slightly easier way too.

Starting with the expression we had before (the one with the double integral):
[tex]\frac{d}{dt} \left\{ \int^{1}_{0} \int^{yt}_{-\infty}f(x) f(y) dxdy \right\}[/tex]

Substitute f(y) = 1, since it's the uniform distribution. Then just reverse the order of the outer integral and the derivative so that you can apply the fundamental theorem of calculus directly to the inner derivative-integral combination.

[tex]\int^{1}_{0} \, \frac{d}{dt} \left\{ \int^{yt}_{-\infty}f(x) dx \right\}\,\, dy[/tex]
Hint: [itex]y[/itex] is a constant with respect to the derivative, so you can replace [itex]\frac{d}{dt}[/itex] with [itex]y \, \frac{d}{d(yt)}[/itex].

You end up with a very easy integral.

In your first equation you are guilty of a very serious error (more of sloppiness than misunderstanding): never, never use the same f for two different distributions. You should either use subscripts, like this [itex]f_X(x)\text{ and } f_Y(y)[/itex] or use different letters, such as [itex]f(x) \text{ and } g(y).[/itex] Believe me, using the same symbol for two different things in the same calculation leads to serious errors eventually.

RGV