pl.show()

pl.figure(2)
pl.clf()
pl.plot(sigmas, lognormalmass_integrals)
pl.xlabel(r'$\sigma_s$')
pl.ylabel(r'$\int P_M(s)$')

pl.figure(3)
pl.clf()
fits = []
for s in sigmas[::10]:
    distr = lognormal_massweighted(rho, 1, s)
    L, = pl.loglog(rho,distr, label=r'$\sigma_s=%f' % s, linewidth=3, alpha=0.5)
    (fitted_rho0,fitted_s),cov = curve_fit(lognormal, rho, distr, p0=[np.exp(s**2),s])
    fitted_distr = lognormal(rho, fitted_rho0, fitted_s)
    pl.loglog(rho,fitted_distr,color=L.get_color(), linestyle='--')
    fits.append((fitted_rho0,fitted_s))
fits = np.array(fits)

pl.xlabel(r'$\rho$')
pl.ylabel(r'$P_M(s)$')
pl.axis([1e-10,1e30,1e-10,1])

pl.figure(4)
pl.clf()
pl.plot(meanrhos, lognormal_integrals_rho)
pl.xlabel(r'$\rho_0$')
pl.ylabel(r'$\int P_V(s)$')
pl.show()
pl.figure(3)
pl.clf()
fits = []
for s in sigmas[::10]:
    distr = lognormal_massweighted(rho, 1, s)
    L, = pl.loglog(rho,
                   distr,
                   label=r'$\sigma_s=%f' % s,
                   linewidth=3,
                   alpha=0.5)
    (fitted_rho0, fitted_s), cov = curve_fit(lognormal,
                                             rho,
                                             distr,
                                             p0=[np.exp(s**2), s])
    fitted_distr = lognormal(rho, fitted_rho0, fitted_s)
    pl.loglog(rho, fitted_distr, color=L.get_color(), linestyle='--')
    fits.append((fitted_rho0, fitted_s))
fits = np.array(fits)

pl.xlabel(r'$\rho$')
pl.ylabel(r'$P_M(s)$')
pl.axis([1e-10, 1e30, 1e-10, 1])

pl.figure(4)
pl.clf()
pl.plot(meanrhos, lognormal_integrals_rho)
pl.xlabel(r'$\rho_0$')
pl.ylabel(r'$\int P_V(s)$')
pl.show()
import pylab as pl
import numpy as np
import hopkins_pdf
from turbulent_pdfs import lognormal

def normalize(arr, normfunc=np.sum):
    return arr/normfunc(arr)

pl.rc('font',size=24)
meandens_4 = 15
xdens = np.linspace(-6,10,1000)
for fignum,sigma in enumerate((0.5,1,1.5,2.0,2.5)):

    rho = 10**xdens
    distr = lognormal(dens=rho, meandens=meandens_4, sigma=sigma)

    pl.figure(fignum)
    pl.clf()
    #pl.plot(rho,distr_mass,label='Mass-weighted PDF',linewidth=2.0)
    pl.plot(rho,normalize(distr),    label='Lognormal $P_V$',color='k', linestyle='-')
    pl.plot(rho,normalize(rho*distr),label='Lognormal $P_M$',color='k', linestyle='--')
    #pl.plot(10**(xdens+log(10)),distr_mass,":",label='Volume-weighted PDF scaled')
    #pl.plot(rho,massgauss,'--',label='Mass gaussian')
    #pl.plot(rho,taildens,'k--',label='with High Tail')
    #pl.plot(rho,taildenspower,'k:',label='with powerlaw Tail')
    #pl.plot(rho,powertail,label='powerlaw Tail')
    #pl.plot(rho,tail,label='High Tail')
    #pl.loglog(rho,hightail_distr(meandens_4,sigma,dens=xdens),label='High Tail',linewidth=2, alpha=0.5)
    #pl.loglog(rho,lowtail_distr(meandens_4,sigma,dens=xdens),label='Low Tail',linewidth=2, alpha=0.5)
    #pl.loglog(rho,compressive_distr(meandens_4,sigma,dens=xdens),label='Compressive',linewidth=2, alpha=0.5)
    #pl.loglog(rho,compressive_distr(meandens_4,sigma,dens=xdens,sigma2=sigma*0.6,secondscale=1.2,offset=1.9),label='Compressive2',linewidth=3, alpha=0.5)