Skip to main content
added 48 characters in body
Source Link
Karsten7
  • 27.6k
  • 5
  • 74
  • 135

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]

data2

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}

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]

data2

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


 

Without Interpolation that area can be calculated with

Total@data2[[# ;;, 2]]*z[[-1]]/Length@data2[[# ;;]] &[Sequence @@  
   FirstPosition[data2[[All, 1]], _?Positive]]

$\ $0.226713

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]

data2

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

The final result depends on the chosen InterpolationOrder (with the default being 3):

NIntegrate[
   Interpolation[data2, InterpolationOrder -> #][x], {x, 0, Max@z}] & /@ Range[0, 5]

$\ ${0.227745, 0.227182, 0.227303, 0.227143, 0.227002, 0.227153}

added 220 characters in body
Source Link
Karsten7
  • 27.6k
  • 5
  • 74
  • 135

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]

data2

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


Without Interpolation that area can be calculated with

Total@data2[[# ;;, 2]]*z[[-1]]/Length@data2[[# ;;]] &[Sequence @@  
  FirstPosition[data2[[All, 1]], _?Positive]]

$\ $0.226713

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]

data2

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

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]

data2

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


Without Interpolation that area can be calculated with

Total@data2[[# ;;, 2]]*z[[-1]]/Length@data2[[# ;;]] &[Sequence @@  
  FirstPosition[data2[[All, 1]], _?Positive]]

$\ $0.226713

deleted 1 character in body
Source Link
Karsten7
  • 27.6k
  • 5
  • 74
  • 135

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]

data2

data2

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

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]

data2

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

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]

data2

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

Source Link
Karsten7
  • 27.6k
  • 5
  • 74
  • 135
Loading