Estimate the expectation E[f(X)] from samples of X by averaging f over the samples.
Implement solve(f, samples).
Returns. Return a float. An empty sample gives nan.
Example 1
Input:
solve(lambda s: s**2, [1.0, 2.0, 3.0])
Output:
4.666667
Example 2
Input:
solve(lambda s: s, [0.0, 10.0])
Output:
5.0
No results yet
Run your code to check it against the examples, or submit to run every test.