from math import*
from random import*

def simvar(V,P,n):
    N=[0,0,0,0]
    y=P[0]
    z=y+P[1]
    t=z+P[2]
    for i in range(n):
        a=random()
        if 0<a<y:
            N[0]=N[0]+1
        if y<a<z:
            N[1]=N[1]+1
        if z<a<t:
            N[2]=N[2]+1
        if a>t:
            N[3]=N[3]+1
    F=[N[0]/n,N[1]/n,N[2]/n,N[3]/n]
    return(F)


def moysimvar(V,P,n):
    E=0
    F=simvar(V,P,n)
    for i in range(4):
        E=E+V[i]*F[i]
    return (E)

def moyvar(V,P):
    E=0
    for i in range(len(V)):
        E=E+V[i]*P[i]
    return(E)

def dist(V,P,n):
    m=moysimvar(V,P,n)
    mu=moyvar(V,P)
    d=abs(m-mu)
    return(d)















