Example #1
0
 def empiricalDistributionPlot(self, sample, bounds=None):
     if bounds:
         lower = bounds[0]
         upper = bounds[1]
     else:
         lower = min(sample)
         upper = max(sample)
     plotDomain = linspace(lower, upper, len(sample))
     empiricalCDF = ECDF([uniform(0, 1) for i in range(len(sample))])
     empiricalCDF.observations = sample
     obs = []
     for j in range(len(sample)):
         obs.append(empiricalCDF(plotDomain[j]))
     ecdf_sample = array(obs)
     plt.plot(plotDomain, ecdf_sample)
     plt.show()
Example #2
0
defosequence = []
for t in range(sampleSize):
    defosequence.append(defo_ad_pf(initial_land, costshocks[t]) - initial_land)

defosequence_ad = array(defosequence) * landtoemissions / 1e6

defosequence = []
for t in range(sampleSize):
    defosequence.append(defo_pf(initial_land, costshocks[t]) - initial_land)

defosequence_defo = array(defosequence) * landtoemissions / 1e6

lower = min(min(defosequence_defo), min(defosequence_ad))
upper = max(max(defosequence_defo), max(defosequence_ad))
plotDomain = linspace(lower, upper, len(costshocks))
empiricalCDF = ECDF([uniform(0, 1) for i in range(len(costshocks))])
empiricalCDF.observations = defosequence_ad
obs = []
for j in range(sampleSize):
    obs.append(empiricalCDF(plotDomain[j]))
ecdf_sample_ad = array(obs)
plt.plot(plotDomain, ecdf_sample_ad, label='AD')
empiricalCDF.observations = defosequence_defo
obs = []
for j in range(sampleSize):
    obs.append(empiricalCDF(plotDomain[j]))
ecdf_sample_defo = array(obs)
plt.plot(plotDomain, ecdf_sample_defo, label='Defo')
plt.legend()
plt.show()
Example #3
0
                ])  # calculate sum E-fields at obsevation points
                Emags2 = abs(numpy.array([numpy.dot(a, a) for a in Es]))
                av = sum(Emags2) / N_obs_points  # the average of |E|**2
                ma = max(Emags2)  # the maximum of |E|**2
                D = ma / av  # directivity
                #print mc, ma, av, D
                Ds.append(D)
                Eslist.append(Es)
            D_max_list.append(numpy.mean(Ds))
            D_max_var_list.append(numpy.var(Ds))
            #ED=EDmax_hansen(ka, mu=1., Ns=Ns)
            # print
            #print f, ka, sum(Ds)/N_MC, ED
            print f, N_obs_points
            #sys.stdout.flush()
            ecdfD = ECDF(Ds)

        #pylab.plot(deval, [FD_hertz_one_cut(d) for d in deval], label="Theoretical CDF (a=0 m)")
        #pylab.plot(deval, [FD_hertz_one_cut_costheta(d) for d in deval], label="Theoretical CDF cos(theta)(a=0 m)")
        pylab.figure(1)
        pylab.plot(N_obs_points_list,
                   D_max_list,
                   '%s+-' % clr,
                   label="f=%dGHz" % (f / 1e9))
        output_data1.append(D_max_list)
        pylab.figure(2)
        pylab.plot(N_obs_points_list,
                   D_max_var_list,
                   '%s+-' % clr,
                   label="f=%dGHz" % (f / 1e9))
        output_data2.append(D_max_var_list)
        Es = numpy.array([
            E_hertz_far(r, p, R, pha, f, t=0, epsr=1.) for r in rs
        ])  # calculate sum E-fields at obsevation points

        Emags2 = abs(numpy.array([numpy.dot(a, a) for a in Es]))

        av = sum(Emags2) / N_obs_points  # the average of |E|**2
        ma = max(Emags2)  # the maximum of |E|**2
        D = ma / av  # directivity
        #print mc, ma, av, D
        Ds_K.append(D)
        Es2_list_av_K.append(av)
        print "K", mc
    Es2_ratio = numpy.divide(Es2_list_max_R, Es2_list_av_K)
    ecdfD = ECDF(Es2_ratio)
    pylab.figure(1)
    pylab.plot(deval, ecdfD(deval), '%s+-' % clr, label="ECDF (Dipoles)")
    output_data.append(remove_nan(ecdfD(deval)))
    #pylab.plot(deval, [FD_hertz_one_cut(d) for d in deval], label="Theoretical CDF (a=0 m)")
    #pylab.plot(deval, [FD_hertz_one_cut_costheta(d) for d in deval], label="Theoretical CDF cos(theta)(a=0 m)")
    pylab.axis([deval[0], deval[-1], 0, 1])
    pylab.grid()
    pylab.legend(loc=4)
    pylab.xlabel(r"$\frac{E^{R^{2}}_{max}}{E^{K^{2}}}$")
    pylab.ylabel(r"F($\frac{E^{R^{2}}_{max}}{E^{K^{2}}}$)")
    pylab.title("$N_{dipoles}=%d$, MC runs=%d, $Frequency=%dGHz$, $R=%dm$" %
                (N_dipole, N_MC, f / 1e9, distance))
    #pylab.show()
    fig = matplotlib.pyplot.gcf()
    fig.set_size_inches(18.5, 10.5)
Example #5
0
defosequence = []
for t in range(sampleSize):
    defosequence.append(defo_ad_pf(initial_land, costshocks[t]) - initial_land)

defosequence_ad = array(defosequence) * landtoemissions / 1e6

defosequence = []
for t in range(sampleSize):
    defosequence.append(defo_pf(initial_land, costshocks[t]) - initial_land)

defosequence_defo = array(defosequence) * landtoemissions / 1e6

lower = min(min(defosequence_defo), min(defosequence_ad))
upper = max(max(defosequence_defo), max(defosequence_ad))
plotDomain = linspace(lower, upper, len(costshocks))
empiricalCDF = ECDF([uniform(0, 1) for i in range(len(costshocks))])
empiricalCDF.observations = defosequence_ad
obs = []
for j in range(sampleSize):
    obs.append(empiricalCDF(plotDomain[j]))
ecdf_sample_ad = array(obs)
plt.plot(plotDomain, ecdf_sample_ad, label='AD')
empiricalCDF.observations = defosequence_defo
obs = []
for j in range(sampleSize):
    obs.append(empiricalCDF(plotDomain[j]))
ecdf_sample_defo = array(obs)
plt.plot(plotDomain, ecdf_sample_defo, label='Defo')
plt.legend()
plt.show()