# gaussian_quadrature.py
"""Volume 2 Lab 12: Gaussian Quadrature.
"""
# Problem 1
def shift(f, a, b, plot=False):
"""Shift the function f on [a, b] to a new function g on [-1, 1] such that
the integral of f from a to b is equal to the integral of g from -1 to 1.
Inputs:
f (function): a scalar-valued function on the reals.
a (int): the left endpoint of the interval of integration.
b (int): the right endpoint of the interval of integration.
plot (bool): if True, plot f over [a,b] and g over [-1,1] in separate
subplots.
Returns:
The new, shifted function.
"""
raise NotImplementedError("Problem 1 Incomplete")
# Problem 2
def estimate_integral(f, a, b, points, weights):
"""Estimate the value of the integral of the function f over [a,b].
Inputs:
f (function): a scalar-valued function on the reals.
a (int): the left endpoint of the interval of integration.
b (int): the right endpoint of the interval of integration.
points ((n,) ndarray): an array of n sample points.
weights ((n,) ndarray): an array of n weights.
Returns:
The approximate integral of f over [a,b].
"""
raise NotImplementedError("Problem 2 Incomplete")
# Problem 3
def construct_jacobi(gamma, alpha, beta):
"""Construct the Jacobi matrix."""
raise NotImplementedError("Problem 3 Incomplete")
# Problem 4
def points_and_weights(n):
"""Calculate the points and weights for a quadrature over [a,b] with n
points.
Returns:
points ((n,) ndarray): an array of n sample points.
weights ((n,) ndarray): an array of n weights.
"""
raise NotImplementedError("Problem 4 Incomplete")
# Problem 5
def gaussian_quadrature(f, a, b, n):
"""Using the functions from the previous problems, integrate the function
'f' over the domain [a,b] using 'n' points in the quadrature.
"""
raise NotImplementedError("Problem 5 Incomplete")
# Problem 6
def normal_cdf(x):
"""Use scipy.integrate.quad() to compute the CDF of the standard normal
distribution at the point 'x'. That is, compute P(X <= x), where X is a
normally distributed random variable with mean = 0 and std deviation = 1.
"""
raise NotImplementedError("Problem 6 Incomplete")