我有一个问题,要减去两个直方图并计算它的CD
F和Kolmogorov Smirnov Test
。我有两个文件的数据,其中一个是最大的,我有缩放。然后我把这些文件放在直方图中,我试着用减法计算CDF
,但我做不到
input_file1="F:/JavierRengifo/Datos/muon_counter_data_Test_Th15_Tamb_LuzNormal.txt" input_file2="F:/JavierRengifo/Datos/muon_counter_data_Sr01uCi_dist05cm_Th15_Det1_NM.txt" input_file3="F:/JavierRengifo/Datos/muon_counter_data_Ce025uCi_dist05cm_Th15_Det1_NM.txt"
df1 = pd.read_table(input_file1,delimiter=' ',skiprows=5, header=0)
df2 = pd.read_table(input_file2,delimiter=' ',skiprows=5, header=0)
df3 = pd.read_table(input_file3,delimiter=' ',skiprows=5, header=0)
arr1=df1["SiPM[mV]"]
arr2=df2["SiPM[mV]"]
arr3=df3["SiPM[mV]"]
BINS=100
(counts, bins) = np.histogram(arr1, bins=BINS)
factor = 1/6
arr1n=plt.hist(bins[:-1], bins, weights=factor*counts, cumulative=False, density=True, color='blue', alpha=0.75, histtype='step')
arr2n=plt.hist(arr2, bins=BINS, cumulative=False, density=True, color='red', alpha=0.75, histtype='step')
arr3n=plt.hist(arr3, bins=BINS, cumulative=False, density=True, color='orange', alpha=0.75, histtype='step')
dfAB = arr2n[0]-arr1n[0]
dfAC = arr3n[0]-arr1n[0]
lala1=plt.hist(diffABv0, bins=100, cumulative=True, density=True, color='red', alpha=0.75, histtype='step')
lala2=plt.hist(diffACv0, bins=100, cumulative=True, density=True, color='purple', alpha=0.75, histtype='step')
print('1 intento Ks: '+str(ks_2samp(dfAB,dfAC)))
目前没有回答
相关问题 更多 >
编程相关推荐