Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multivariate integration #48

Open
Alexander-Murray opened this issue Jan 19, 2021 · 2 comments
Open

Multivariate integration #48

Alexander-Murray opened this issue Jan 19, 2021 · 2 comments

Comments

@Alexander-Murray
Copy link

Alexander-Murray commented Jan 19, 2021

Hey, I tried following the tutorial examples here but I can't seem to figure out the right syntax for multivariate integration. Here is what I am trying:

deg = [3, 5, 6, 4]
d = minimum(deg)
op1 = GaussOrthoPoly(deg[1], addQuadrature=true);
op2 = Uniform01OrthoPoly(deg[2], addQuadrature=true);
op3 = Beta01OrthoPoly(deg[3], 2, 1.2, addQuadrature=true);
ops = [op1, op2, op3];
mop = MultiOrthoPoly(ops, d);
integrate((a,b,c,d) -> a*b*c*d, mop)

however, I get the following error:

type MultiOrthoPoly has no field quad

Stacktrace:
 [1] getproperty(::MultiOrthoPoly{ProductMeasure,Quad{Float64,Array{Float64,1}},Array{AbstractCanonicalOrthoPoly{Array{Float64,1},M,Quad{Float64,Array{Float64,1}}} where M,1}}, ::Symbol) at .\Base.jl:33
 [2] integrate(::Function, ::MultiOrthoPoly{ProductMeasure,Quad{Float64,Array{Float64,1}},Array{AbstractCanonicalOrthoPoly{Array{Float64,1},M,Quad{Float64,Array{Float64,1}}} where M,1}}) at C:\Users\mrra\.julia\packages\PolyChaos\AlY80\src\auxfuns.jl:96
 [3] top-level scope at In[5]:8
 [4] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091

Is there any way of doing this with the PolyChaos package?

@Alexander-Murray
Copy link
Author

One solution is to use multiple univariate integrals:

deg = [3, 5, 6, 4]
op1 = GaussOrthoPoly(deg[1], addQuadrature=true);
op2 = Uniform01OrthoPoly(deg[2], addQuadrature=true);
op3 = Beta01OrthoPoly(deg[3], 2, 1.2, addQuadrature=true);
ops = [op1, op2, op3];
integrate(c->integrate(b->integrate((a)->a*b*c, op1),op2),op3)

however, I'd be interested to hear about other approaches.

@timueh
Copy link
Collaborator

timueh commented May 19, 2021

hi Alex, yes, multiple univariate integrals is the way to proceed.

Put differently, there is not support for generic multivariate integration, only integration of product measures for which you can decompose the $n$-variate integral to $n$ univariate integrals. For each of the $n$ univariate integrals you can then use the quad rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants