clustering/gmm_lda/gmm/plot_normal.py
def draw2dnormal(norm, show = False, axes = None):
    """
    Just draw a simple 2d normal pdf.
    """
    # create a meshgrid centered at mu that takes into account the variance in x and y
    delta = 0.025

    lower_xlim = norm.mu[0] - (2.0 * norm.E[0,0])
    upper_xlim = norm.mu[0] + (2.0 * norm.E[0,0])
    lower_ylim = norm.mu[1] - (2.0 * norm.E[1,1])
    upper_ylim = norm.mu[1] + (2.0 * norm.E[1,1])

    x = np.arange(lower_xlim, upper_xlim, delta)
    y = np.arange(lower_ylim, upper_ylim, delta)

    X,Y = np.meshgrid(x,y)

    # remember sqrts!
    Z = matplotlib.mlab.bivariate_normal(X, Y, sigmax=np.sqrt(norm.E[0,0]), sigmay=np.sqrt(norm.E[1,1]), mux=norm.mu[0], muy=norm.mu[1], sigmaxy=norm.E[0,1])

    minlim = min(lower_xlim, lower_ylim)
    maxlim = max(upper_xlim, upper_ylim)

    # Plot the normalized faithful data points.
    if not axes:
        fig = pl.figure(num = 1, figsize=(4,4))
        pl.contour(X,Y,Z)
        #axes.set_xlim(minlim,maxlim)
        #axes.set_ylim(minlim,maxlim)
    else:
        axes.contour(X,Y,Z)
        #axes.set_xlim(minlim,maxlim)
        #axes.set_ylim(minlim,maxlim)

    if show:
        pl.show()

    Just draw a simple 2d normal pdf.
    
Just draw a simple 2d normal pdf.
Just draw a simple 2d normal pdf .
def draw2dnormal(norm, show = False, axes = None):
    delta = 0.025
    lower_xlim = norm.mu[0] - (2.0 * norm.E[0,0])
    upper_xlim = norm.mu[0] + (2.0 * norm.E[0,0])
    lower_ylim = norm.mu[1] - (2.0 * norm.E[1,1])
    upper_ylim = norm.mu[1] + (2.0 * norm.E[1,1])
    x = np.arange(lower_xlim, upper_xlim, delta)
    y = np.arange(lower_ylim, upper_ylim, delta)
    X,Y = np.meshgrid(x,y)
    Z = matplotlib.mlab.bivariate_normal(X, Y, sigmax=np.sqrt(norm.E[0,0]), sigmay=np.sqrt(norm.E[1,1]), mux=norm.mu[0], muy=norm.mu[1], sigmaxy=norm.E[0,1])
    minlim = min(lower_xlim, lower_ylim)
    maxlim = max(upper_xlim, upper_ylim)
    if not axes:
        fig = pl.figure(num = 1, figsize=(4,4))
        pl.contour(X,Y,Z)
    else:
        axes.contour(X,Y,Z)
    if show:
        pl.show()
def draw2dnormal ( norm , show = False , axes = None ) : delta = 0.025 lower_xlim = norm . mu [ 0 ] - ( 2.0 * norm . E [ 0 , 0 ] ) upper_xlim = norm . mu [ 0 ] + ( 2.0 * norm . E [ 0 , 0 ] ) lower_ylim = norm . mu [ 1 ] - ( 2.0 * norm . E [ 1 , 1 ] ) upper_ylim = norm . mu [ 1 ] + ( 2.0 * norm . E [ 1 , 1 ] ) x = np . arange ( lower_xlim , upper_xlim , delta ) y = np . arange ( lower_ylim , upper_ylim , delta ) X , Y = np . meshgrid ( x , y ) Z = matplotlib . mlab . bivariate_normal ( X , Y , sigmax = np . sqrt ( norm . E [ 0 , 0 ] ) , sigmay = np . sqrt ( norm . E [ 1 , 1 ] ) , mux = norm . mu [ 0 ] , muy = norm . mu [ 1 ] , sigmaxy = norm . E [ 0 , 1 ] ) minlim = min ( lower_xlim , lower_ylim ) maxlim = max ( upper_xlim , upper_ylim ) if not axes : fig = pl . figure ( num = 1 , figsize = ( 4 , 4 ) ) pl . contour ( X , Y , Z ) else : axes . contour ( X , Y , Z ) if show : pl . show ( )
Just draw a simple 2d normal pdf.
Just draw a simple 2d normal pdf .
"""
    Just draw a simple 2d normal pdf.
    """ # create a meshgrid centered at mu that takes into account the variance in x and y # remember sqrts! # Plot the normalized faithful data points. #axes.set_xlim(minlim,maxlim) #axes.set_ylim(minlim,maxlim) #axes.set_xlim(minlim,maxlim) #axes.set_ylim(minlim,maxlim)
norm
show
axes