Monte Carlo Method for Probabilities and Expectations

Calculate the probability of an event:
Obtain an estimate based on simulation:
Calculate the expectation for an expression:
Obtain an estimate based on simulation: