예제 #1
0
파일: RADfits.py 프로젝트: klocey/MicroMETE
def getPredRADs(N, S, Nmax):
    
    PRED = []
    
    # Predicted geometric series
    predRAD = predRADs.get_GeomSeries(N, S, False) # False mean no zeros allowed
    PRED.append(predRAD)
    
    # Predicted log-series
    logSeries = mete.get_mete_rad(S, N)
    predRAD = logSeries[0]
    PRED.append(predRAD)
    
    # Predicted PLN
    predRAD = pln.get_rad_from_obs(RAD, 'pln') 
    PRED.append(predRAD)
    
    sample_size = 10
    # Predicted from compositions (basically geometric series)
    predRAD = getPred(N, S, maxn, 'compositions', sample_size)
    PRED.append(predRAD)
    
    # Predicted from Fraction 1: Power Fraction
    predRAD = getPred(N, S, maxn, 'power fraction', sample_size)
    PRED.append(predRAD)
    
    # Predicted from Fraction 2: Random non-preemption
    predRAD = getPred(N, S, maxn, 'random fraction non-preemption', sample_size)
    PRED.append(predRAD)
    
    # Predicted from Fraction 3: Random preemption 
    predRAD = getPred(N, S, maxn, 'random fraction', sample_size)
    PRED.append(predRAD)
    
    return PRED
예제 #2
0
def get_MLEs(RAC, sample_size):

    sample = []
    while len(sample) < sample_size:
        RAC = pln.get_rad_from_obs(RAC, 'pln')
        sample.append(np.var(RAC, ddof=1))
        #print 'MLEs:', len(sample)

    #plt.plot(sample)
    #plt.show()

    return sample
예제 #3
0
def get_LogNormMLE(RAC):
    varlst = [1, 2, 3]

    VarOfVars = 1

    while VarOfVars > 0.01:  # while the variance of varlst is greater than zero

        RAC = pln.get_rad_from_obs(RAC, 'pln')  #get RAC from pln
        varlst.append(np.var(
            RAC, ddof=1))  # add the variance of the end RAC to the list
        varlst.pop(0)  # remove the first number in the varlst

        print varlst
        VarOfVars = np.var(varlst, ddof=1)
        break

    return RAC
예제 #4
0
파일: Global.py 프로젝트: klocey/MicroMETE
def plot_RADs_canonical(N, S):

    fig = plt.figure()
    ax = fig.add_subplot(1,1,1)

    # Predicted geometric series
    print 'generating geometric series'
    t0 = time.time()
    predRAD = get_GeomSeries(N, S, False) # False mean no zeros allowed
    t = time.time() - t0
    print 'time for geometric series:',t
    ranks = range(1, S+1)
    plt.plot(ranks, predRAD, lw = 1, c='m')

    # Predicted log-series
    print 'generating log-series'
    t0 = time.time()
    logSeries = mete.get_mete_rad(S, N)
    t = time.time() - t0
    print 'time for log-series:',t
    predRAD = logSeries[0]
    ranks = range(1, S+1)
    plt.plot(ranks, predRAD, lw = 1, c='c')

    # Predicted PLN
    print 'generating Poisson log-normal'
    t0 = time.time()
    predRAD = pln.get_rad_from_obs(predRAD, 'pln')
    t = time.time() - t0
    print 'time for log-normal:',t
    ranks = range(1, len(predRAD)+1)
    plt.plot(ranks, predRAD, lw = 1, c='gray')

    plt.yscale('log')
    plt.savefig('/Users/lisalocey/Desktop/RareBio/figs/GlobalRADs_N='+str(int(N))+'_S='+str(int(S))+'.png',dpi=600)

    plt.show()

    return
예제 #5
0
        RAC.sort()
        RAC.reverse()
        sample.append(RAC)

    return sample


fig = plt.figure()
ax = plt.subplot(1, 1, 1)

S = 500
RAD = np.random.logseries(0.99, S)
RAD.tolist()

RAD = pln.get_rad_from_obs(RAD, 'pln')
print sum(RAD), len(RAD)
RADs = SimLogNorm(sum(RAD), len(RAD), 10000)
print sum(RADs[0]), len(RADs[0])

x = []
y = []

for RAD in RADs:
    seed()
    y.extend(np.log(RAD))
    x.extend(range(len(RAD)))

plt.hexbin(x, y, mincnt=1, bins='log', cmap=plt.cm.jet)
plt.plot(np.log(RAD), color='k', lw=4)
plt.xlim(0, S)