Syntax error to generate Log Normal Variables

I would like to generate 2x4 matrix of values which are log normally distributed
with mu= 1.175 and sigma = 0.0768 .. However when I write the following command
A= lognrnd(1.175,0.0768,2,4);
It appears the ouput error as follows:
??? Undefined function or method 'lognrnd' for input arguments of type 'double'.
Can any person please help me to resolve the issue ?

댓글 수: 2

It is a Statistics Toolbox function.
Type:
which lognrnd -all
on the Command Line to see if it exists on your system, and to be sure there is only one function with that name.
Jav Neo
Jav Neo 2012년 9월 13일
Thanks Star ... I have checked and it says that I dont have licence avaliable ...
Is there Any alternate way to generate log normal random values???

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

 채택된 답변

Matt Fig
Matt Fig 2012년 9월 13일
편집: Matt Fig 2012년 9월 13일

0 개 추천

Use this instead:
A = exp(randn(2,4).*0.0768+1.175)
Or make a little function:
Lognrand = @(S,mu,sig) exp(randn(S).*sig+mu);
A = Lognrand([2,4],1.175,0.0768);
To check:
m = 5/3;
v = 7/5;
mu = log((m^2)/sqrt(v+m^2));
sigma = sqrt(log(v/(m^2)+1));
A = Lognrand([1,1e7],mu,sigma);
abs(mean(A)-m)/m % Should be pretty small
abs(var(A)-v)/v

댓글 수: 2

Jav Neo
Jav Neo 2012년 9월 13일
What S stand here ??
Matt Fig
Matt Fig 2012년 9월 13일
Like I show, S is the size. So S=[2,4] means you will get a 2-by-4 array.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Exponents and Logarithms에 대해 자세히 알아보기

제품

질문:

2012년 9월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by