SciML / PolyChaos.jl

A Julia package to construct orthogonal polynomials, their quadrature rules, and use it with polynomial chaos expansions.
https://docs.sciml.ai/PolyChaos/stable/
MIT License
115 stars 26 forks source link

Sampling Uniform_11OrthoPoly #84

Open urp1 opened 1 year ago

urp1 commented 1 year ago

I am getting many warnings with the following message and Julia freezes indefinitely:

┌ Warning: ignoring keyword method; sampling from Distributions.jl instead
└ @ PolyChaos JULIA_DIR\PolyChaos\THVqe\src\polynomial_chaos.jl:208`

when executing the last command in the following code:

N = 100;
x = sampleMeasure(N, Uniform01OrthoPoly(5));
y = sampleMeasure(N, Uniform_11OrthoPoly(5))

Any ideas on what may be causing errors when sampling Uniform_11OrthoPoly but not when sampling Uniform01OrthoPoly?

Thanks

timueh commented 1 year ago

Hi @urp1,

I'm sorry you're experiencing this kind of inconvenience.

tl; dr: currently, Uniform_11OrthoPoly is using a different sampling function than Uniform01OrthoPoly. This should be undone, and then solve your problem.

Off the top of my head, I am not sure what's causing this. Here are my thoughts though:

When sampling Uniform010OrthoPoly(5) you are essentially using Distributions.jl to sample, see the code here.

When you're sampling for Uniform_11Orthopoly, you are not using Distributions.jl, but you're probably ending up here.

Now, the following would be nice (and solve your issues): sampling from the uniform distributions on [-1, 1] is essentially the same as sampling from the canonical uniform distribution defined on [0, 1]. Hence, it would be nice to use the same sampling function for [-1, 1] as for [0, 1] (the one from Distributions.jl). Of course, there would have to be a straightforward translation step necessary..

Does this make sense to you?