Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- prob_of_sign = .25
- weight_probs = { # this is the solution they prefer
- '3': prob_of_sign,
- '3': prob_of_sign,
- '2': prob_of_sign,
- '5': prob_of_sign
- }
- expectation = sum(
- [int(x_i)*weight_probs[x_i] for x_i in weight_probs]
- )
- expectation_of_squares = sum(
- [int(x_i)*int(x_i)*weight_probs[x_i] for x_i in weight_probs]
- )
- square_of_expectation = expectation**2
- variance = expectation_of_squares - square_of_expectation
- print('Expected value:', expectation)
- print('Variance:', variance)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement