PDF = sqrt((u.^3)./pi).*exp(-u.*(x.^2)) + sqrt((1-u)^3/pi).*exp(-(1-u).*x.^2)
So we have two terms there.
syms u positive syms x real
Look at the first term:
pdf1 = sqrt((u.^3)./pi).*exp(-u.*(x.^2)); int(pdf1,x,[-inf,inf]) ans = u
So, it integrates to u. The second term is similar,
pdf2 = sqrt(((1-u).^3)./pi).*exp(-(1-u).*(x.^2)); int(pdf2,x,[-inf,inf]) ans = piecewise([u == 1, 0], [1 < u, Inf*1i], [u < 1, 1 - u])
N = 10000000; u = 0.01; % random mixture selection % Here s will be 1 if the element is sampled from first pdf. % s will be 0 if the element is sampled from second pdf. s = rand(1,N) < u; % sample using randn, with a unit variance initially x = randn(1,N);; % now scale each element based on the desired variance x(s) = x(s)*sqrt(2/u); x(~s) = x(~s)*sqrt(2/(1-u)); hist(x,1000)
pdf1 = @(x,u) sqrt((u.^3)./pi).*exp(-u.*(x.^2)); pdf2 = @(x,u) sqrt(((1-u).^3)./pi).*exp(-(1-u)); h1 = ezplot(@(x) pdf1(x,0.25),[-10,10]); hold on h2 = ezplot(@(x) pdf2(x,0.25),[-10,10]); title 'pdf1 and pdf2, split apart'
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.