def expect_mc(dist, func=lambda x: 1, size=50000):
    def fun(x):
        return func(x) # * dist.pdf(x)
    rvs = dist.rvs(size=size)
    return fun(rvs).mean(0)
calculate expected value of function by Monte Carlo integration
dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/sandbox/distributions/mv_normal.py/expect_mc