Beispiel #1
0
def plotBinomials(dataMatrix,nVals,p):
    nTrials = nVals.size # rows are the trials
    # same the mean and variances...
    means = np.zeros(nTrials)
    varReal = np.zeros(nTrials)
    varDist = np.zeros(nTrials)
    for i,n in enumerate(nVals):
        means[i],varReal[i],varDist[i] =\
                    plotSingleHist(n,p,dataMatrix[i,:],outDir)
    # plot the means and variances
    fig = pPlotUtil.figure()
    plt.subplot(1,2,1)
    plt.title("Mean of g(xBar)-g(mu) approaches 0",fontsize=fontsize)
    expMean = 0
    plt.plot(nVals,means,'ko',label="Actual Mean")
    plt.axhline(expMean,color='b',linestyle='--',
                label="Expected Mean: {:.2g}".format(expMean))
    plt.ylim(-min(means),max(means)*1.1)
    plt.xlabel("Value of n for binomial",fontsize=fontsize)
    plt.ylabel("Value of g(xBar)-g(mu)",fontsize=fontsize)
    plt.legend(fontsize=fontsize)
    pPlotUtil.tickAxisFont()
    plt.subplot(1,2,2)
    plt.semilogy(nVals,varReal,'ko',label="Actual Variance")
    plt.semilogy(nVals,varDist,'b--',label="Expected Variance")    
    plt.title("Variance of g(xBar)-g(mu)\n approaches expected",
              fontsize=fontsize)
    plt.xlabel("Value of n for binomial",fontsize=fontsize)
    plt.ylabel("Value of g(xBar) variance",fontsize=fontsize)
    pPlotUtil.tickAxisFont()
    plt.legend(fontsize=fontsize)
    pPlotUtil.savefig(fig,outDir + "MeanVar")
Beispiel #2
0
def plotSingleHist(n,p,xTrials,outDir):
    # coverage is just a plotting artifact
    fig = pPlotUtil.figure()
    # mu: expected value of Binomial(n,p)
    # effectie variance
    dist,distMean,distVar,normalStd,normalDist,xVals,nBins = \
                            getDeltaModelDistr(n,p,xTrials)
    normV = normHist(dist,nBins,\
                     label=("Actual Distr: Mean={:.4f},Stdev={:.4f}").\
                     format(distMean,np.sqrt(distVar)))
    rawPDF = normalDist.pdf(xVals)
    plt.plot(xVals,rawPDF,'r--',linewidth=5.0,
             label="Theorertical Distr: Stdev={:.4f}".\
             format(normalStd))
    plt.title("Histogram for g(xBar)-g(mu) for n={:d},p={:.2f}".\
              format(int(n),p),fontsize=g_title)
    plt.xlabel("(g(Xbar)-g(mu)) ~ Normal(0,[g'(x)*sigma]^2/n)",
               fontsize=g_label)
    plt.ylabel("Proportion",fontsize=g_label)
    plt.legend(frameon=False)
    pPlotUtil.tickAxisFont()
    catArr = list(rawPDF) + list(normV)
    plt.ylim([0,max(catArr)*1.2])
    plt.xlim([-max(nBins),max(nBins)])
    pPlotUtil.tickAxisFont()
    pPlotUtil.savefig(fig,outDir + "trial_n{:d}".format(int(n)))
    #return the statistics for plotting
    return distMean,distVar,normalStd**2
Beispiel #3
0
def plotSingleHist(n, p, xTrials, outDir):
    # coverage is just a plotting artifact
    fig = pPlotUtil.figure()
    # mu: expected value of Binomial(n,p)
    # effectie variance
    dist,distMean,distVar,normalStd,normalDist,xVals,nBins = \
                            getDeltaModelDistr(n,p,xTrials)
    normV = normHist(dist,nBins,\
                     label=("Actual Distr: Mean={:.4f},Stdev={:.4f}").\
                     format(distMean,np.sqrt(distVar)))
    rawPDF = normalDist.pdf(xVals)
    plt.plot(xVals,rawPDF,'r--',linewidth=5.0,
             label="Theorertical Distr: Stdev={:.4f}".\
             format(normalStd))
    plt.title("Histogram for g(xBar)-g(mu) for n={:d},p={:.2f}".\
              format(int(n),p),fontsize=g_title)
    plt.xlabel("(g(Xbar)-g(mu)) ~ Normal(0,[g'(x)*sigma]^2/n)",
               fontsize=g_label)
    plt.ylabel("Proportion", fontsize=g_label)
    plt.legend(frameon=False)
    pPlotUtil.tickAxisFont()
    catArr = list(rawPDF) + list(normV)
    plt.ylim([0, max(catArr) * 1.2])
    plt.xlim([-max(nBins), max(nBins)])
    pPlotUtil.tickAxisFont()
    pPlotUtil.savefig(fig, outDir + "trial_n{:d}".format(int(n)))
    #return the statistics for plotting
    return distMean, distVar, normalStd**2
Beispiel #4
0
def plotBinomials(dataMatrix, nVals, p):
    nTrials = nVals.size  # rows are the trials
    # same the mean and variances...
    means = np.zeros(nTrials)
    varReal = np.zeros(nTrials)
    varDist = np.zeros(nTrials)
    for i, n in enumerate(nVals):
        means[i],varReal[i],varDist[i] =\
                    plotSingleHist(n,p,dataMatrix[i,:],outDir)
    # plot the means and variances
    fig = pPlotUtil.figure()
    plt.subplot(1, 2, 1)
    plt.title("Mean of g(xBar)-g(mu) approaches 0", fontsize=fontsize)
    expMean = 0
    plt.plot(nVals, means, 'ko', label="Actual Mean")
    plt.axhline(expMean,
                color='b',
                linestyle='--',
                label="Expected Mean: {:.2g}".format(expMean))
    plt.ylim(-min(means), max(means) * 1.1)
    plt.xlabel("Value of n for binomial", fontsize=fontsize)
    plt.ylabel("Value of g(xBar)-g(mu)", fontsize=fontsize)
    plt.legend(fontsize=fontsize)
    pPlotUtil.tickAxisFont()
    plt.subplot(1, 2, 2)
    plt.semilogy(nVals, varReal, 'ko', label="Actual Variance")
    plt.semilogy(nVals, varDist, 'b--', label="Expected Variance")
    plt.title("Variance of g(xBar)-g(mu)\n approaches expected",
              fontsize=fontsize)
    plt.xlabel("Value of n for binomial", fontsize=fontsize)
    plt.ylabel("Value of g(xBar) variance", fontsize=fontsize)
    pPlotUtil.tickAxisFont()
    plt.legend(fontsize=fontsize)
    pPlotUtil.savefig(fig, outDir + "MeanVar")
Beispiel #5
0
def plotScoreHistograms(scores,fontSize,edgecolor='none'):
    meanScore = np.mean(scores)
    stdevScore = np.std(scores)
    step = 1
    bins = np.arange(min(scores)-step,max(scores)+step,1)
    plt.hist(scores, bins,normed=True,label="Distr. "+
             "mean:{:.3g}, var: {:.3g})".format(meanScore,stdevScore**2),
             alpha=0.25,edgecolor=edgecolor)
    plt.xlabel("Optimal alignment score for sequence",fontsize=fontSize)
    plt.ylabel("Occurence of score",fontsize=fontSize)
    pPlotUtil.tickAxisFont()
    return meanScore,stdevScore,bins