[R] variance?,...

Rostislav Matl xmatl at informatics.muni.cz
Mon Nov 22 20:04:49 CET 1999


hi

I'm learning R and making some examples.
One of them is that for given distribution
I show density function, distribution function
expected value and variance(?).
I know 
EX <- function(xval,xprob) sum( (xval*xprob) );
where xval is vector of values and xprob vector of probabalities,
but
DX <- function(xval,xprob) EX((xval^2),xprob) - (EX(xval,xprob))^2;
doesn't work as I thought.
I've looked intto FAQs and archives but my question
is probably too simple. 
Can somebody tell me what's wrong on my example ?
And one more question: when I'm plotting density:
plot(x, dnorm(x,as.double(mu),as.double(sigma_square)), style );
on interval x I get relatively small number of probabilities.
I've spent long time searching trough docs to find how
to change it but didn't found it. So please tell me how.

thanks for replies
+-----------------------------------------------------------------------------+
|  ROSTISLAV MATL, student of Masaryk University - Faculty of Informatics     |
|  e-mail: xmatl at fi.muni.cz      WWW: http://www.fi.muni.cz/~xmatl/index.html | 
|  ICQ#: 17058749                                                             |
+-----------------------------------------------------------------------------+
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list