def makeCDF(probability, edges): probability = nrm.normalizeCounts(probability, edges) widths = (edges[1:] - edges[:-1]) widths = np.array(widths) # Compute the CDF CY = np.cumsum(probability * widths) return CY
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jul 24 10:53:26 2019 @author: Emilio Moya University of Michigan """ import matplotlib.pyplot as plt import spectraMultiDependence_v2 as spmd import probDistributionOfToFSum as pdfs import normalize as nrm [ctsExperiment, expBins] = spmd.plotExp() [ctsSimulation, simBins] = pdfs.plotSim() normExp = nrm.normalizeCounts(ctsExperiment, expBins) normSim = nrm.normalizeCounts(ctsSimulation, simBins) centersExp = nrm.edgesToCenters(expBins) centersSim = nrm.edgesToCenters(simBins) plt.plot(centersExp, normExp, label = "Experiment") plt.plot(centersSim, normSim, label = "Null Hypothesis") plt.ylabel("Normalized Counts") plt.xlabel("Energy Sum Between Two Neutrons (MeV)") plt.legend() plt.show()
simTimes3 = neutrons[neutrons.PulseHeight > minHeight3].Time #Creates bins for simulation and experimental data simBins = np.linspace(5, simTimes.max(), 101) simBins2 = np.linspace(5, simTimes2.max(), 101) simBins3 = np.linspace(5, simTimes3.max(), 101) expBins = np.linspace(5, expTimes.max(), 101) #Computes the histogram of the experiment and simulation data [yExp, xExp] = np.histogram(expTimes, expBins) [ySim, xSim] = np.histogram(simTimes, expBins) [ySim2, xSim2] = np.histogram(simTimes2, expBins) [ySim3, xSim3] = np.histogram(simTimes3, expBins) #Normalizes the experiment and simulation data normExp = nrm.normalizeCounts(yExp, xExp) normSim = nrm.normalizeCounts(ySim, xSim) normSim2 = nrm.normalizeCounts(ySim2, xSim2) normSim3 = nrm.normalizeCounts(ySim3, xSim3) #Finds the bins centers of the experiment and simulation bins centersExp = nrm.edgesToCenters(expBins) centersSim = nrm.edgesToCenters(expBins) centersSim2 = nrm.edgesToCenters(expBins) centersSim3 = nrm.edgesToCenters(expBins) ##Plots the normalized experiment and simulation data, with axises, a title, and a legend #plt.plot(centersExp, normExp, alpha = 0.5, label = "Experiment") #plt.plot(centersSim, normSim, alpha = 0.5, label = "Simulation 1 (Min Height = 0.1)") #plt.plot(centersSim2, normSim2, alpha = 0.5, label = "Simulation 2 (Min Height = 0.5)") #plt.plot(centersSim3, normSim3, alpha = 0.5, label = "Simulation 3 (Min Height = 1)")