필터 지우기
필터 지우기

how to write the randn' s code with just using rand and CLT

조회 수: 2 (최근 30일)
alireza kooshafar
alireza kooshafar 2016년 2월 19일
답변: jgg 2016년 2월 19일
I wrote this code but I didn't get the correct answer from it. i don't know where the problem is. thank for help
clc
clear all
m = input( 'please enter the number of LINES:');
n = input( 'please enter the number of ROWS:');
y = zeros(m,n);
G = zeros(m,n);
x = rand(m,n);
y= 0.2*x+32;
s(1)=y(1);
s(m*n)=sum(sum(y));
for i= 3: m*n
s(i-1)= s(i-2) + y(i-1);
end
G = zeros(m,n);
for i= 1:m*n
G(i) = s(i)/(i) ;
end
disp(G)
hist(G)
  댓글 수: 4
alireza kooshafar
alireza kooshafar 2016년 2월 19일
@Walter Roberson
Central Limit Theorem
@jgg
thanks yes you are right about the fault but I have no idea about using Cumulative distribution function here
and I am just going to write randn's code by using rand and the way is not importent
jgg
jgg 2016년 2월 19일
If you don't care about the method, see the answer below.

댓글을 달려면 로그인하십시오.

채택된 답변

jgg
jgg 2016년 2월 19일
Since you don't actually want to use the CLT, then inverse sampling is your solution.
notrandn = @(n,m)(norminv(rand(n,m),0,1));
out = notrandn(10000,1);
out2 = randn(10000,1);
ecdf(out)
hold on
ecdf(out2)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by