Problem 44286. Compute average gain for some bets.
Given a vector containg the odds of some events in decimal format (e.g., odds=[1.3 2.5 1.5] ) and a vector of the same dimensions containing the amount of dollars that you are betting for each of those (e.g., bets=[100 10 80] ), the function avg_gain(odds,bets) should return the average of the gain for each possible outcome. The average is a simple average and should not weight the events by their actual probability. Moreover it needs to be rounded to the second decimal digit.
Example: odds= [1.1] bets= [100]
there are only two possible outcomes in this simple case:
- Item one I win the bet: I gain 100*1.1 -100 dollars= +10 dollars
- Item two I lose the bet: I just lose the bet of 100 dollars = -100 dollars.
So I need to perform an average of -100 and 10 that is -45.
Disclaimer: a positive average does not mean that betting is a good idea, since we are only performing a simple average, ignoring the probabilities of the different events. I want in no way encourage betting since it is risky and sometimes addictive. It's just a simple Cody problem, take it for what it really is.
Solution Stats
Problem Comments
-
3 Comments
????
Please revise problem statement to indicate that summation is required, such as:
"the function avg_gain(odds,bets) should return the SUM of each bet's average gain (averaged for each possible outcome)"
It is not obvious from the example.
As stated by David, it is required to sum the averages after the calculation.
Solution Comments
Show commentsProblem Recent Solvers28
Suggested Problems
-
Find the sum of all the numbers of the input vector
47688 Solvers
-
Similar Triangles - find the height of the tree
286 Solvers
-
Return the first and last characters of a character array
9406 Solvers
-
Sum the 'edge' values of a matrix
335 Solvers
-
488 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!