print("[","|"*int(t/times*10)," "*int(10-t/times*10),"]",izpis, "% time: ",time.time()-timeStart) print() izpis += 10 for s in range(0,noStars): all1 = 1 for i in range(0,noParameters): if random.random()>random.uniform(0,0.2): all1 = 0 if(all1==1): summ+=1 elements[t]=summ ''' for s in range(0, noStars): if random.random() <= 0.1**noParameters: summ += 1 elements[t] = summ (xaxis, yaxis) = createHistogram(elements, range(0, 200)) save(xaxis, yaxis, 'Toy model 4 parameters brez') #yaxis = fl.gaussian_filter(yaxis, 10) #hist1 = np.histogram(elements,range(0,100)) #plt.hist(elements,bins=range(0,400)) #plt.plot(hist1) #plt.show()
@author: benos ''' from IO import readFile, save import numpy as np from logHistogramAdd import logHistogramAddMult from mpSampleMultiple import scale (xaxis, yaxis) = readFile("sigma is 50.csv") size = len(yaxis) start = 0 end = np.log(xaxis[-1]) dist = [0] * size izpis = 0 lastIndex = 1 for i in range(0, size): if yaxis[i] == 0: continue (lastIndex, dist) = logHistogramAddMult(start, end, size, dist, xaxis[i] + 1, yaxis[i], lastIndex) if i % (size / 10) == 0: print(izpis, "%") izpis += 10 save(scale(start, end, size), dist, 'Sigma is 50 plus 1') print('done')
elements = [0] * (times + 1) izpis = 0 for t in range(0, times + 1): summ = 0 ''' if t % (times / 10) == 0: print("[","|"*int(t/times*10)," "*int(10-t/times*10),"]",izpis, "% time: ",time.time()-timeStart) print() izpis += 10 for s in range(0,noStars): all1 = 1 for i in range(0,noParameters): if random.random()>random.uniform(0,0.2): all1 = 0 if(all1==1): summ+=1 elements[t]=summ ''' for s in range(0, noStars): if random.random() <= 0.1**noParameters: summ += 1 elements[t] = summ (xaxis, yaxis) = createHistogram(elements, range(0, 200)) save(xaxis, yaxis, 'Toy model 6 parameters')
from nicePsevdoPDF import getPDFNice #dejanski program: start = -100 stop = 100 pdfSize = 10000 size = 30000 xOs, pdf = getDistributionOfEks(size, pdfSize, low=start, high=stop, printOn=1) cdf = getCDFNIC(pdf) pdf[0] = pdf[1] #pdf=normalizePDF(pdf) l = mp.linspace(start, stop, pdfSize) xOs = [mp.power(10, x) for x in l] pdf = fl.gaussian_filter(pdf, 10) save(xOs, pdf, "L with laplace") save(xOs, cdf, "L with laplace cdf") #cdf = getCDFNIC(pdf) pdfNice = getPDFNice(xOs, pdf) print("done") #save(xOs, pdfNice , "pdfNice 200") #plt.xscale('log') #plt.plot(xOs, pdfNice, 'blue', label = 'pdfNice' ) #plt.plot(xOs, cdf, 'red', label = 'cdf' ) #plt.legend( loc=4 ) #plt.plot([1,1],[0,1],'green') #p.fill(xOs, pdf, facecolor='blue', alpha=0.5)
from IO import save def key_gen(n): #生成大素数 for _ in range(4): p = get_large_prime_length(n) q = get_large_prime_length(n) while (p == q): q = get_large_prime_length(n) print(p) print(q) n = p * q n1 = (p - 1) * (q - 1) #默认为65537 e = 65537 r, d, l = t.ext_gcd(e, n1) if d < 0: d = d + n1 return p, q, n, e, d if __name__ == "__main__": p, q, n, e, d = key_gen(20) save(p, "p.txt") save(q, "q.txt") save(n, "n.txt") save(e, "e.txt") save(d, "d.txt")
from lifeDist import lifeDist, lifeDist2 from logHistogramAdd import logHistogramAddMult from mpLogspace import mpLogspace data = readData("laplace_cutoff_correction") siz = len(data) formatted = [0] * siz sortedData = np.sort(data) saveData(sortedData, "laplace_cutoff_correction_sorted") lastIndex = 0 dist = [0] * siz start = -40 end = 15 size = siz for value in sortedData: (lastIndex, dist) = logHistogramAddMult(start, end, size, dist, value, 1, lastIndex) xaxis = mpLogspace(10**-40, 10**15, siz) save(xaxis, dist, "laplace_cutoff_correction_sorted") print("done")
Fintelligence = mpLogUniform(0.001, 1, size) Fcivilization = mpLogUniform(0.01, 1, size) Length = mpLogUniform(100, 10000000000, size) ''' Rstar = (1, 100) Fplanets = (0.1, 1) Nhabitable = (0.1, 1) # Flife = lognormal(10**(-40),1,size) # Flife = loguniform(1,1000,size) # Flife = (0,1,lifeDist(size,size/2)) # Flife = (mpmathify(10 ** (-156)), 1) Fintelligence = (0.001, 1) Fcivilization = (0.01, 1) Length = (100, 10000000000) ''' Flife = (1, -35, 15, 14, 17, 0, 50) N = readFile('sigma is 50.csv') (xaxis, yaxis) = sampleL([Rstar, Fplanets, Nhabitable, Fintelligence, Fcivilization], -100, 100, size, 230000, Flife, (1, N)) save(xaxis, yaxis, 'What is L with N sig50') Flife = (1,-35,15,14,17,0,100) (xaxis, yaxis) = mpSampleMultipleTime([Rstar, Fplanets, Nhabitable, Fintelligence, Fcivilization, Length],-120,15, size, 50000,Flife) save(xaxis, yaxis, 'sigma is 100') ''' Flife = (1,-35,15,14,17,0,200)
''' Created on 13 Aug 2018 @author: benos ''' import time from meanMedian import meanMedian from IO import save, readFile import scipy.ndimage.filters as fl import matplotlib.pyplot as plt from createGraph import createGraph from StandardizeDistribution import StandardizeDistributionW import numpy as np (xaxis, yaxis) = readFile("laplace_new") ''' xaxis2=[0]*len(xaxis) xaxis2[0]=np.round(np.log10(xaxis[0])) yaxis[0]=int(yaxis[0]) for i in range(1,len(xaxis)): xaxis2[i]=int(np.round(np.log10(xaxis[i]))) yaxis[i]=int(yaxis[i]) save(xaxis2,yaxis,"sigma is 100 exponents") ''' avg = 0 for i in range(0, len(xaxis)): avg += yaxis[i] * xaxis[i] avg /= sum(yaxis) print(sum(yaxis))
allRand *= random.random() * 0.2 ''' for s in range(0, noStars): allRand = 1 for i in range(0, noParameters): #allRand *= random.uniform(0, 0.2) allRand *= random.random()*0.2 if(random.random() < allRand): summ += 1 elements[t] = summ ''' for s in range(0,noStars): if random.random()<=0.1**noParameters: summ+=1 elements[t]=summ ''' (xaxis, yaxis) = createHistogram(elements, range(0, 200)) save(xaxis, yaxis, 'Toy model 5 parameters uniform bad') # yaxis = fl.gaussian_filter(yaxis, 10) # hist1 = np.histogram(elements,range(0,100)) # plt.hist(elements,bins=range(0,400)) # plt.plot(hist1) # plt.show()