Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: calculate maximum density of normal distribuion


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: calculate maximum density of normal distribuion
Date   Fri, 22 Nov 2013 15:32:54 +0000

You're right. Try maximum density = normalden(0)/SD for your case.
Nick
[email protected]


On 22 November 2013 15:28, Nick Bornschein <[email protected]> wrote:
> Here is the code I'm using, change mean and sd at the beginning and look at
> the graph, the density is not the same:
>
> clear
>
> set obs 10000
> set seed 2211
> global mean = 5
> global sd = 3
> gen normal1 = rnormal($mean, $sd)
>
> qui: su normal1
> global min = r(min)
> global min = round($min,.01)
> display $min
>
> qui: su normal1
> global max = r(max)
> global max = round($max,.01)
> display $max
>
> _pctile normal1, p(2.5)
> global n1_1 = r(r1)
> global n1_1 = round($n1_1,.01)
> display $n1_1
>
> _pctile normal1, p(97.5)
> global n1_2 = r(r1)
> global n1_2 = round($n1_2,.01)
> display $n1_2
>
> twoway  function y=normalden(x,$mean,$sd), range($min $max) color(r) ||
> ///
> function y=normalden(x,$mean,$sd), range($min $n1_1) recast(area)
> color(dknavy) ||          ///
>         function y=normalden(x,$mean,$sd), range($n1_2 $max) recast(area)
> color(dknavy)             ///
>         xtitle("{it: {&mu}}")                                      ///
>         xline($mean)                                 ///
>         ytitle("") title("Normalverteilung")
> ///
>         subtitle("{&mu}=$mean {&sigma}=$sd mit {&alpha}=.05, 2-seitig")
> ///
>         legend(off) xlabel($n1_1 $mean $n1_2)
>
>
>
>
> Am 22.11.13 16:12, schrieb Nick Cox:
>>
>> That density is a constant, namely
>>
>>
>> . di normalden(0)
>> .39894228
>>
>> Whatever mean a normal has just shifts the distribution left or right,
>> so makes no difference to what the peak density is; hence without loss
>> of generality we can focus on mean 0.
>>
>> Whatever SD a normal has, 0/SD is still 0.
>>
>> Correct me if I'm wrong....
>> Nick
>> [email protected]
>>
>>
>> On 22 November 2013 15:00, Nick Bornschein <[email protected]>
>> wrote:
>>>
>>> Hello,
>>>
>>> I'm calculating a normal distribution with:
>>>
>>> set obs 10000
>>> set seed 2211
>>> gen normal2 = rnormal($mean2, $sd2)
>>>
>>> by given mean and sd which I define via global macro.
>>>
>>> Is it possible to calculate the maximum density at the mean point?
>>> And more interesting: is it possible to define "xline" until a given
>>> point
>>> at the y axis (the maximum density as you can imagine) because I want to
>>> add
>>> the mean line with going higher than the maximum density?
>>>
>>> Best
>>> -Nick
>>> *
>>> *   For searches and help try:
>>> *   http://www.stata.com/help.cgi?search
>>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>>> *   http://www.ats.ucla.edu/stat/stata/
>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>> *   http://www.ats.ucla.edu/stat/stata/
>>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index