1. "Multiply the distribution with a continuous function (i.e. x^3)"
I'll call the new data data2
data2 = Transpose@{z, frequency*z^3}
ListPlot[data2, Axes -> True, Joined -> True, PlotRange -> All]
2. "NIntegrate
the whole thing"
An InterpolatingFunction
for data2
can be found with
data2IP = Interpolation[data2]
and numerically integrated with
NIntegrate[data2IP[x], {x, 0, Max@z}]
$\ $0.227143
WithoutThe final result depends on the chosen InterpolationInterpolationOrder
that area can be calculated with(with the default being 3):
Total@data2[[#NIntegrate[
;; Interpolation[data2, 2]]*z[[-1]]/Length@data2[[#InterpolationOrder ;;]]-> &[Sequence#][x], @@{x, 0,
Max@z}] & FirstPosition[data2[[All,/@ 1]]Range[0, _?Positive]]5]
$\ ${0.226713227745, 0.227182, 0.227303, 0.227143, 0.227002, 0.227153}