Closed Sumit9013 closed 1 year ago
Your are not missing anything. Quadrature rules does not garanty that 0 should be included. For distributions symmetric around origo (like yours), 0 is typically included at even order.
Your example is quite similar to Gauss-Legendre quadrature. Take a look at the Wikipedia article for an overview.
Hello Dr,
We are trying to reproduce the results in a paper which adds 0 for odd orders. We are looking to implement Improved Probabilistic collocation method (IPCM) where for the candidate of the (i+1)th collocation point, the (i+1)th row of the matrix should be linearly independent with the previous ith rows. Therefore, the rank of this matrix is calculated and judged whether it is equal to the row of this matrix. If it is equal, this candidate is preserved or otherwise abandoned. Then the point with next highest probability density is tested. The matrix is the co-efficient matrix and the process is stopped when the rows of the matrix is equal to the number of undetermined co-efficients. I have attached the paper and the snip of the collocation nodes for your reference. I would have been a great help if this is added in chaospy. 7498526.pdf
Thank you
From the paper they say that they just add 0 for every odd terms. For your one-dimensional case, I don't see why you can not do this manually after quadrature generation. Like:
gauss_quads, _ = chaospy.generate_quadrature(Poly_order, X1, rule="gaussian")
if Poly_order % 2 == 1:
gauss_quads = np.concatinate([[0], gauss_quads])
Does that solve your issue, or do you need multivariate support?
Thank you Dr Jonathan. Yes we need support for the multivariate case. Some of my colleagues argue that additionally to adding 0 to the gauss nodes, the weights are also being redistributed to account for the additional nodes. For example, now for odd order '3' we get 4 nodes and 4 weights. After adding 0 the nodes become 5 and we need an additional weight for node '0' (to numerically solve the integral and calculate coefficients) but redistribute for all other nodes as well because sum(weights) = 1. Is there a paper with such conclusions and improved accuracy or computation time? I however think that they are adding 0 just to create arrays of sampling points and calculating the co-efficients by Regression (PCM). I have also edited the code which works for me:
gauss_quads, _ = chaospy.generate_quadrature(Poly_order, X1, rule="gaussian")
zero=np.array([[0]])
if Poly_order % 2 == 1:
gauss_quads = np.concatenate((zero, gauss_quads), axis=1)
Okay.
Take a look at help(chaospy.quadrature.hypercube.hypercube_quadrature)
in a Python REPL.
It is a helper function that transforms 1-D quadrature fuctions into N-D.
So if you wrap your quadrature rule with padding of 0 for both nodes and weights and make the call signature what hypercube expects, you should be able to construct your multivariate quadrature.
Let me know if you need help.
Hello Dr,
I am using the function below for generating collocation nodes. The result however has everything except 0.
Output is:
If Poly_order is even then we get a node at e-17 which can be assumed to 0, but for odd orders its not giving 0 Could you please let me know where I could have been possibly missing something
Thanks