- #1
confused_engineer
- 39
- 2
Hello everyone. I have a Python code which calculates, given a continuos uniform random variable U(-1,1), the order of a interpolation polynomial and a set of points the evolution of a function of this random variable. i.e.
v0 = cp.Uniform(-1,1)
t = np.linspace(0, 10, 10)
order=1
.
.
.
plt.plot (t, v0*t)
and it returns the Nodes, Weights, Mean and Variances in each of the 10 points.
I want to replicate this by hand.
I have no issue with the zeros, since I just have to find the ones of (½)*x*(5*x2-3), but I don't know how to calculate the weights. I am following the book Numerical Methods for Stochastic Computations A Spectral Method Approach by Dongbin Xiu (page 40), where it suggests that I should write wj(N)=Integrate lj(N)wdx.
Does this means that I shoud integrate (½)*x*(5*x2-3) multiplied by the random variable U(-1, 1)? Am I understanding this wrong? I don't know how to integrate a random variable...
v0 = cp.Uniform(-1,1)
t = np.linspace(0, 10, 10)
order=1
.
.
.
plt.plot (t, v0*t)
and it returns the Nodes, Weights, Mean and Variances in each of the 10 points.
I want to replicate this by hand.
I have no issue with the zeros, since I just have to find the ones of (½)*x*(5*x2-3), but I don't know how to calculate the weights. I am following the book Numerical Methods for Stochastic Computations A Spectral Method Approach by Dongbin Xiu (page 40), where it suggests that I should write wj(N)=Integrate lj(N)wdx.
Does this means that I shoud integrate (½)*x*(5*x2-3) multiplied by the random variable U(-1, 1)? Am I understanding this wrong? I don't know how to integrate a random variable...
Last edited by a moderator: