%pylab inline
import scipy as sp

"""
Explanation: Import NumPy and SciPy (not needed when using --pylab)
End of explanation
"""


zz = np.loadtxt('wiggleZ_DR1_z.dat',dtype='float'); # Load WiggleZ redshifts

"""
Explanation: Load data from file
End of explanation
"""


np.min() # Check bounds

np.max()

"""
Explanation: Check bounds
End of explanation
"""


nbins = 50; # Is this a good choice? 

n, bins, patches = hist() # With hist, one needs to (spuriously) request the patch objects as well

x = bins[0:nbins] + (bins[2]-bins[1])/2; # Convert bin edges to centres, chopping the last

"""
Explanation: Construct histogram from data
There are several histrogram commands: hist() will be fine here, but note the syntax below. Also note that the bin edges are returned, so that there will nbins+1 of these.
End of explanation
"""


# Import the function you need
from scipy.interpolate import interp1d

# Build an interpolation function for p(z) that accepts an arbitrary redshift z

z = linspace(0,2,100); plot(z,p(z)) # Test your interpolation function out

"""
Explanation: Interpolate histogram output -> p(z); n.b. that you can also use numerical quadrature to get $P(z)$ directly.
End of explanation
"""


# Import the function you need
from scipy import integrate

Pz = lambda : ... # Use integrate inside a lambda function to define P(z)?

total = Pz(5) # Get normalisation constant by evaluating P(z->\infty)

total # Check that this worked

"""
Explanation: Use numerical integration to get $P(z) = \int_0^\infty p(z') dz'$
End of explanation
"""


