prob2pdf takes a vector of probabilities and a spatial grid (given by end-points and interfaces) and computes the average p.d.f. in each grid cell
prob2pdf(phi, xgrid, ygrid = c(0, 1))
length(phi) must equal length(xgrid)-1, if ygrid is not given, or (length(xgrid)-1)*(length(ygrid)-1) if ygrid is given
xgrid (and ygrid, if given) must be strictly increasing