Hi there,
Given a grid of points on the x axis, let gridx, and a grid of points on the y axis, let gridy, and the values of some surface, let Z, I can draw the surface
surf(gridx,gridy,Z)
and calculate the volume under it by
volume=abs(trapz(trapz(gridy,Z),gridx))
or by
volume=trapz(gridy,trapz(gridx,Z,2),1)
(It is actually a bivariate density and I can verify that is approximately equal to one so everything is fine here.
Now I want to do the same (i.e. calculate the volume) under a trivariate density.
I have gridx, gridy, gridz, and P (where P are the values of the hyperface)
I would assume that one would achive this by
matvolume=trapz(gridz,trapz(gridy,trapz(gridx,P,3),2),1)
but this does not yield anything close to 1.
Isn't that correct? Thank you in advance for any answers.