Skip to content

Area of density

4 messages · pragmatic, Duncan Murdoch, Rolf Turner

#
Hello!
Please, anybody help me.

Can I calculate area of density was created by:
In other words I want to know area under curve 'plot(D)'
and It's good to calculate area before and after 0 separately.
#
On 05/09/2008 4:32 PM, pragmatic wrote:
That should be 1.
That's harder, but a good approximation should be sum(x < 0)/length(x) 
and sum(x > 0)/length(x).

Duncan Murdoch
#
On 6/09/2008, at 8:32 AM, pragmatic wrote:

            
(1) You could use splinefun()

	foo <- splinefun(D$x,D$y)
	integrate(foo,min(D$x),0)
	integrate(foo,0,max(D$x))

or you could use simp() from

	http://finzi.psych.upenn.edu/R/Rhelp02a/archive/134918.html

	with(D,simp(y=y[x<0],x=x[x<0]))
	with(D,simp(y=y[x>0],x=x[x>0]))

You'll get different answers, neither of which is ``correct''.

	cheers,

		Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}