0

I have a velocity distribution which has a complicated normalization factor. Without that factor it's integral is 0.95. I'm using Monte Carlo to generate the same velocity distribution. I wanted to check my generated array of velocity to see if it works fine. The shape of plotting it shows that it is but I wanted to know if there is any way to make python to make a histogram that is normalized to an arbitrary value? Thanks all in advance.

   def VelocityDistribution (velocity):
       v = velocity
       v0 = 220

       ve = v0*(1.05)
       return 100/95.2032*np.sqrt(1/np.pi) * (v/(v0*ve)) * (np.exp((-(v-
   v0)**2)/(v0**2)) - np.exp((-(v+v0)**2)/(v0**2)))
   v = np.linspace(0,800,10000)
   v0 = 220
   ve = v0*(1.05)

    VelocityDistribution1 = 100/95.2032*np.sqrt(1/np.pi) * (v/(v0*ve)) * (np.exp((-(v-v0)**2)/(v0**2)) - np.exp((-(v+v0)**2)/(v0**2)))
    i=0
    V = []
    while i < 100000:
        randPro = random.uniform(0.0, 0.003)
        randv = random.uniform(0,800)
        if VelocityDistribution(randv) >= randPro :
            V.append(randv)
            i+=1
    plt.hist(V, bins = 80, normed = 0.80)
    plt.title("Velocity Distribution of WIMP particles")
    plt.xlabel('Velocity (km/s)')
    plt.ylabel('Probability')
    plt.plot(v, VelocityDistribution1, 'r')
    plt.show()
  • 1
    Can you give an example of what you are asking? Please post your code. – James Oct 18 '17 at 01:05
  • so if you plot the above code you will see that the actual distribution is not perfectly normalized, it's not the other way around because I find the integral of the function using Mathematica. I wanted to see if there are any option in histogram that make the integral of the distribution to be equal to some arbitrary number? I know I can multiply my own equation be a constant to bring back everything but I'm just checking on plt.hist options. Thanks. – Sina Safarabadi Oct 18 '17 at 02:26

0 Answers0