[R] function of probability for normal distribution

Charles C. Berry cberry at tajo.ucsd.edu
Thu Jan 20 04:29:29 CET 2011


On Wed, 19 Jan 2011, JClark wrote:

>
>
> Dear Greg Snow,
>
> I'm a biologist trying to write a mathematical formula for a doubly
> truncated normal distribution to be used in the language "R". I realise this
> is simple stuff for a mathematician but I'm stumped.
> Wikipedia gives what seems a fairly simple formula - with function = maths
> with mean and standard deviation - but also phi - WHAT IS PHI !!?? -


On

 	http://en.wikipedia.org/wiki/Truncated_normal_distribution

it says (by copy-and-paste)

"The density function involves \scriptstyle{\phi(\cdot)} \ , which is the 
probability density function of the standard normal distribution and 
\scriptstyle{\Phi(\cdot)} \ , its cumulative distribution function."

There are some links there that you can follow to get up to speed.

> especially how do I write this in "R" and why is the top "phi" in italics ??

Hmmm. Try the posting guide's suggestions. This seems to help:

 	?distribution
 	[stuff deleted]
 	For the normal distribution see dnorm.

and
 	?dnorm
 	[stuff deleted]
 	dnorm gives the density, pnorm gives the distribution function,
 	qnorm gives the quantile function, and rnorm generates random
 	deviates.

so match up 'density' and 'distribution function' in the ?dnorm page and 
the wiki page and you should be able to put it together.

(FWIW, ?density and ??density are not so helpful.)

BTW

 	 \frac{\frac{1}{\sigma}\phi(\frac{x - \mu}{\sigma})}

(copy and pasted from the wiki page) can be rendered as

 	dnorm(x , mu, sigma ) in R.

HTH,

Chuck

> Hoping you can help.
>
> Yours sincerely,
>
> Jeremy Clark
>
>
>
>
>
>
>
> -- 
> View this message in context: http://r.789695.n4.nabble.com/Re-R-function-for-Probabilities-for-the-standard-normal-distribution-tp903639p3225457.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Charles C. Berry                            Dept of Family/Preventive Medicine
cberry at tajo.ucsd.edu			    UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901



More information about the R-help mailing list