Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Set up boxes
- p = [0.8; 0.15; 0.05];
- X = [10; 30; 80];
- Target_Value = 20;
- %% Reduce smallest probability
- % assume boxes are ordered
- assert(p(1) > 0);
- assert(X(1) < Target_Value);
- assert(Target_Value < X(2));
- % E = p1*X1 + p2*X2 + (1-p1-p2)*X3
- if Target_Value < X(2)
- % We can obtain Target_Value with positive p1.
- c = (p(2)*X(2) + (1-p(1)-p(2))*X(3) - (1-p(1))*Target_Value) / p(1) / (Target_Value - X(1));
- p(1) = c*p(1);
- end
- p = p / sum(p);
- E = p'*X;
- >> E
- E =
- 20.0000
- >> p
- p =
- 0.6923
- 0.2308
- 0.0769
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement