我在减去两个直方图并计算其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,累积= False,密度= True,color ='红色',alpha = 0.75,histtype ='step')
arr3n = plt.hist(arr3,bins = BINS,累积= 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,累积= True,密度= True,color ='红色',alpha = 0.75,histtype ='step')
lala2 = plt.hist(diffACv0,bins = 100,累积= True,密度= True,颜色='紫色',alpha = 0.75,histtype ='step')
print('1 intento Ks:'+ str(ks_2samp(dfAB,dfAC)))