On Sep 8, 2011, at 19:03 , Albyn Jones wrote:
> Look at
>
>area <- sum(a$y)*(a$x[1]-a$y[2])
>
> The problem appears to be "a$x[1]-a$y[2]"; that is not the length of
> the base of an approximating rectangle, whatever it is :-)
I would assume that that is just a typo for a$x[1]-a$x[2], which
Is your "data" supposed to be observations, or values of the density
of the underlying law?
Also, could you explain the rationale behind :
sum(a$y)*(a$x[1]-a$y[2])
because it is not immediately clear to the reader.
2011/9/8 Gonçalo Ferraz :
> Hi, I have a vector 'data' of 58 probability values (b
Look at
area <- sum(a$y)*(a$x[1]-a$y[2])
The problem appears to be "a$x[1]-a$y[2]"; that is not the length of
the base of an approximating rectangle, whatever it is :-)
albyn
On Thu, Sep 08, 2011 at 11:36:23AM -0400, Gonçalo Ferraz wrote:
> Hi, I have a vector 'data' of 58 probability value
ilto:r-help-bounces@r-
> project.org] On Behalf Of Gonçalo Ferraz
> Sent: Thursday, September 08, 2011 9:36 AM
> To: r-help@r-project.org
> Subject: [R] Density function: Area under density plot is not equal to
> 1. Why?
>
> Hi, I have a vector 'data' of 58 probability v
Hi, I have a vector 'data' of 58 probability values (bounded between 0 and 1)
and want to draw a probability density function of these values. For this, I
used the commands:
data <- runif(58)
a <- density(data, from=0, to=1)
plot(a, type="l",lwd=3)
But then, when I try to approximate the area
5 matches
Mail list logo