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

Add transformations for infinite and semi infinite integral. #33

Merged
merged 10 commits into from
Sep 2, 2020

Conversation

ashutosh-b-b
Copy link
Contributor

No description provided.

@ashutosh-b-b
Copy link
Contributor Author

@ChrisRackauckas I applied this to Quadrature Algorithms. Can you check this further so that I can apply this to Cubature as well?

@ChrisRackauckas
Copy link
Member

What do you mean? Cubature is just multi-dimensional quadrature.

@ashutosh-b-b
Copy link
Contributor Author

ashutosh-b-b commented Aug 11, 2020

@ChrisRackauckas No, I meant have I done correctly ? I added the check only to AbstractQuadratureAlgorithm part. And checked it integrating a two dimensional pdf function

@ChrisRackauckas
Copy link
Member

It looks like it's written always assuming that lb and ub is scalar or length 1 which isn't correct, but when that's fixed it should be good to go.

@ashutosh-b-b
Copy link
Contributor Author

It looks like it's written always assuming that lb and ub is scalar or length 1 which isn't correct, but when that's fixed it should be good to go.

No, I have checked this works for vector inputs as well. Should I add a test case as well?

@ChrisRackauckas
Copy link
Member

No, I have checked this works for vector inputs as well. Should I add a test case as well?

Yes, on scalar and vector.

@ashutosh-b-b
Copy link
Contributor Author

@ChrisRackauckas

function transform_inf(t , p , f)
v(t) = t ./ (1 .- t.^2)
if t isa Number
j = ForwardDiff.derivative(v, t)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just write down the analytical solution to the derivatives here?

end

function transformation_if_inf(prob)
if (!(prob.lb isa Number) && all(prob.lb .== -Inf) && all(prob.ub .== Inf)) || (prob.lb == -Inf && prob.ub == Inf)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this could be selectively applied to the directions which are Inf.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, does the transformation hold for that case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can cache the indexes to transform and then if transform, then X otherwise identity.

@ashutosh-b-b
Copy link
Contributor Author

@ChrisRackauckas

@ashutosh-b-b ashutosh-b-b changed the title [WIP] Add transformations for infinite and semi infinite integral. Add transformations for infinite and semi infinite integral. Sep 1, 2020
Comment on lines 57 to 68
if lb isa Number && ub isa Number
if lb == -Inf && ub == Inf
j = (1 .+ t.^2 )/(1 .- t.^2).^2
return f(v_inf(t) , p)*(j)
elseif lb != -Inf && ub == Inf
a = lb
j = 1 ./ ((1 .- t).^2)
return f(v_semiinf(t , a) , p)*(j)
elseif lb == -Inf && ub != Inf
error("Semi Infinte integrals of limits 0 to Inf are supported")
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a separate dispatch

j = 1 ./ ((1 .- t).^2)
return f(v_semiinf(t , a) , p)*(j)
elseif lb == -Inf && ub != Inf
error("Semi Infinte integrals of limits 0 to Inf are supported")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't you just flip the integral to handle this case?

@ChrisRackauckas ChrisRackauckas merged commit bac723f into SciML:master Sep 2, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants