(x, m=None, Cinv=None, sigma=1, detC=None)
return  exp(-np.dot(dx, np.dot(Cinv, dx)) / sigma**2 / 2) / s2pi / abs(detC)**0.5 / sigma**n
return likelihood of x for the normal density N(m, sigma**2 * Cinv**-1)
return likelihood of x for the normal density N(m, sigma**2 * Cinv**-1)
return likelihood of x for the normal density N ( m sigma ** 2 * Cinv ** - 1 )
def likelihood(x, m=None, Cinv=None, sigma=1, detC=None):
        """return likelihood of x for the normal density N(m, sigma**2 * Cinv**-1)"""
        # testing: MC integrate must be one: mean(p(x_i)) * volume(where x_i are uniformely sampled)
        # for i in range(3): print mean([cma.likelihood(20*r-10, dim * [0], None, 3) for r in rand(10000,dim)]) * 20**dim
        if m is None:
            dx = x
        else:
            dx = x - m  # array(x) - array(m)
        n = len(x)
        s2pi = (2*np.pi)**(n/2.)
        if Cinv is None:
            return exp(-sum(dx**2) / sigma**2 / 2) / s2pi / sigma**n
        if detC is None:
            detC = 1. / np.linalg.linalg.det(Cinv)
        return  exp(-np.dot(dx, np.dot(Cinv, dx)) / sigma**2 / 2) / s2pi / abs(detC)**0.5 / sigma**n
def likelihood ( x , m = None , Cinv = None , sigma = 1 , detC = None ) : # testing: MC integrate must be one: mean(p(x_i)) * volume(where x_i are uniformely sampled) # for i in range(3): print mean([cma.likelihood(20*r-10, dim * [0], None, 3) for r in rand(10000,dim)]) * 20**dim if m is None : dx = x else : dx = x - m # array(x) - array(m) n = len ( x ) s2pi = ( 2 * np . pi ) ** ( n / 2. ) if Cinv is None : return exp ( - sum ( dx ** 2 ) / sigma ** 2 / 2 ) / s2pi / sigma ** n if detC is None : detC = 1. / np . linalg . linalg . det ( Cinv ) return exp ( - np . dot ( dx , np . dot ( Cinv , dx ) ) / sigma ** 2 / 2 ) / s2pi / abs ( detC ) ** 0.5 / sigma ** n