[R] lognorm

Ernesto Jardim ernesto at ipimar.pt
Fri Jan 7 16:22:45 CET 2005


Fred,

If you want to produce log normal values you can do it by using rlnorm, 
and you have to provide the mean and variance of the process in log 
scale, wich means after log transform. Or you can produce them with 
rnorm and exponentiate.

Check:

 > set.seed(1)
 > rlnorm(100, 0, 1)->vec
 > set.seed(1)
 > rnorm(100, 0, 1)->vec2
 > all.equal(exp(vec2),vec)
[1] TRUE

In both cases I'm using mean=0 and var=1.

Regards

EJ

Frederic renaud wrote:
> This values come from R. I 've read the doc but...
> If I've understood, I must write
> rlnorm(10000,0,0)) to have a mean = 1 and Var =1
> but that doesn't work (log 1 =0) 
> 
> --- Ernesto Jardim <ernesto at ipimar.pt> wrote:
> 
> 
>>Where did you get those values ?
>>
>> > mean(rlnorm(10000,0,1))
>>[1] 1.667496
>> > var(rlnorm(10000,0,1))
>>[1] 4.666731
>>
>>Look at previous emails, they are more explicit. The
>>basis is that you 
>>must give the mean and variance in log scale.
>>
>>EJ
>>
>>
>>Frederic renaud wrote:
>>
>>>yes but
>>>mean(rlnorm(10000,0,1)) ne 0
>>>and var(rlnorm(10000,0,1)) ne 1
>>>
>>>???
>>>
>>>
>>>
>>>--- Ernesto Jardim <ernesto at ipimar.pt> wrote:
>>>
>>>
>>>
>>>>>args(rlnorm)
>>>>
>>>>function (n, meanlog = 0, sdlog = 1)
>>>>NULL
>>>>
>>>>Frederic renaud wrote:
>>>>
>>>>
>>>>>Hi!
>>>>>I 've a problem to have a lognorm distribution
>>>>
>>>>with
>>>>
>>>>
>>>>>mean=1 and var (or sigma)=1.
>>>>>
>>>>>rlnorm(1000,0,0)
>>>>>rlnorm(1000,1,1)
>>>>>rlnorm(1000,0,1)
>>>>>....                     ?
>>>>>
>>>>>Can you help me?
>>>>>
>>>>>______________________________________________
>>>>>R-help at stat.math.ethz.ch mailing list
>>>>>https://stat.ethz.ch/mailman/listinfo/r-help
>>>>>PLEASE do read the posting guide!
>>>>
>>>>http://www.R-project.org/posting-guide.html
>>>>
>>>
>>>
>>>
>>>__________________________________________________
>>
> 
> 
> 
> 		
> __________________________________ 




More information about the R-help mailing list