You are on page 1of 4

BinomialRomero

February 14, 2017

1 Histograms of the binomial coefficient for different values of N


In [1]: using PyPlot #Import PyPlot

In [2]: function barPlot(N::Int64)

data = Array{BigInt}(N+1,1); #Declare array for the un-normalized


#data, BigInt because the values might be very big

for i in 0:N
data[i+1] = binomial(BigInt(N),i) #Filling the original array
end

ma = maximum(data) #Find the maximum of all those values

dat = Array{Float64}(N+1,1) #Declare new array to store the


#normalized data

for i in 0:N
dat[i+1] = data[i+1]/ma #Fill the array normalizing with
#respect to the maximum value
end

h = plt[:bar](0:N,dat,1) #Plotting the histogram

xlim([0,N+1]) #Declaring the limits for the x axis


grid("on") #Activating the grid view
xlabel("n")
ylabel(L"bin(N,n)/bin(N,N/2)")
title("Histogram for "*L"N=5")
show() #showing the result

end

Out[2]: barPlot (generic function with 1 method)

In [3]: barPlot(5)

1
In [4]: barPlot(10)

2
In [5]: barPlot(100)

3
4

You might also like