Message Boards Message Boards

0
|
8858 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Cumulative Loss Calculation

Posted 9 years ago

There is data that I am trying to calculate its cumulative loss using NIntegrate. Here is the example.

x = Range[1, 10, 1];
y = Range[0.91, 1, 0.01];
soldata = Transpose[{x, y}];
sol = Interpolation[soldata, InterpolationOrder -> 1];

a = Range[1.0, 0.55, -0.05];
b = sol[Range[1, 10, 1]];
c = a*b;
solwave = Range[1, 10, 1];
wtsoldata = Transpose[{solwave, c}];
wtsol = Interpolation[wtsoldata, InterpolationOrder -> 1];

intwtsol = NIntegrate[wtsol[x], {x, 1, 10}];
intsol = NIntegrate[sol[x], {x, 1, 10}];
wttran = intwtsol/intsol 100
cumulloss = 100 - wttran

sol is an example data points, and wtsol is a weighted data points, and wttran is a normalized value (Integration of wtsol / integration of sol) in full range (1~10)

I'd like to calculate "wttran" with varying the range, like 2, 3, ....9, 10. So, I can see its cumulative loss (100-wttran). But when I make it as a function of range, it keeps give me errors.

This is what I tried.

z = Range[2, 10, 1]
intwtsol[z_] = NIntegrate[wtsol[x], {x, 1, z}];
intsol[z_] = NIntegrate[sol[x], {x, 1, z}];
wttran[z_] = intwtsol/intsol 100;
cumulloss = 100 - wttran

Any help will be very appreciable.

POSTED BY: Sungwoo Yang
2 Replies
Posted 9 years ago

Is this what you are looking for

intwtsol = NIntegrate[wtsol[x], {x, 1, #}] & /@ Range[2, 10, 1];
intsol = NIntegrate[sol[x], {x, 1, #}] & /@ Range[2, 10, 1];
wttran = intwtsol/intsol 100
cumulloss = 100 - wttran

?

POSTED BY: Xavier Roy
Posted 9 years ago

Yes, it is working. Thank you so much for your help Xavier.

POSTED BY: Sungwoo Yang
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract