Git Product home page Git Product logo

Comments (8)

robertsawko avatar robertsawko commented on August 18, 2024

I have just confirmed that the problem occurs also for Uniform distribution.

from chaospy.

tsbertalan avatar tsbertalan commented on August 18, 2024

It works for me if I use a rv with a mean of 0. I haven't used chaospy much, but generally high-ish order polynomials work better with mean-0, standard-deviation-1 abscissae. If you can afford to, work in such a space, and then translate any results back to the original space as needed by an appropriate (scaling and) shifting.

Unless this capability is supposed to be built-in to chaospy, which would make sense.

from chaospy.

jonathf avatar jonathf commented on August 18, 2024

As @tsbertalan said. Try to parameterize the problem in terms of standard distributions when going to higher order.

Polynomial chaos expansions allows you to address the problem trough a proxy variable:

from numpy import std
from chaospy import Normal, generate_quadrature, orth_ttr, fit_quadrature, Std

def f(x):
    return x

order = 6
rv = Normal(10, 0.1)
rv_proxy = Normal(0, 1)

data = f(rv.sample(order+1))

nodes, weights = generate_quadrature(order, rv_proxy, rule='G')
P, norms = orth_ttr(order, rv_proxy, normed=False, retall=True)
evals = f(rv.inv(rv_proxy.fwd(nodes[0])))
u_hat = fit_quadrature(P, nodes, weights, evals, norms=norms)
print(Std(u_hat, rv_proxy))
print(std(data))

This approximation works well as long as the mapping between rv and rv_proxy is smooth.

from chaospy.

robertsawko avatar robertsawko commented on August 18, 2024

I just want to say for now, thanks for your feedback and ideas. Both suggestions look like exactly what I was looking for. I will leave it open for now at least before I get the time to properly try it all out. Sorry for late responses.

from chaospy.

robertsawko avatar robertsawko commented on August 18, 2024

Right, I finally sat down and tested it out. Briefly, proxy method rocks. I focused on a variance and used the code below. I take that that the evals in your example simply transform to unit square through forward Rosenblatt and then transform to desired distribution through inverse Rosenblatt.

So clearly this is the property of the method. Is there a place in the literature where this has been described?

def f(x):
    return x**3


def direct(rv, order=4):
    nodes, weights = generate_quadrature(order, rv, rule='G')
    evals = f(nodes[0])

    Ps, norms = orth_ttr(order, rv, normed=False, retall=True)
    u_hat = fit_quadrature(Ps, nodes, weights, evals, norms=norms)
    return Var(u_hat, rv)


def proxy(rv, order=4):
    rv_proxy = Normal(0, 1)
    nodes, weights = generate_quadrature(order, rv_proxy, rule='G')
    evals = f(rv.inv(rv_proxy.fwd(nodes[0])))

    Ps, norms = orth_ttr(order, rv_proxy, normed=False, retall=True)
    u_hat = fit_quadrature(Ps, nodes, weights, evals, norms=norms)
    return Var(u_hat, rv_proxy)

rv = Normal(10, 0.1)

orders = arange(1, 11)
proxy_variance = array([proxy(rv, o) for o in orders])
direct_variance = array([direct(rv, o) for o in orders])

output

from chaospy.

jonathf avatar jonathf commented on August 18, 2024

That is correct, those are Rosenblatt transformations.

Rosenblatt is usually discussed in the context of transforming from and to stochastically independent variables, but the rules are exactly the same applied to achieve stability in higher orders. There should be something more specific to what you are asking out there, but unfortunately I don't remember what they are.

If you want to read up on the transformation itself, then the guys who made the DAKOTA software library discusses the topic here:
https://www.researchgate.net/profile/Michael_Eldred/publication/242068651_Recent_Advances_in_Non-Intrusive_Polynomial_Chaos_and_Stochastic_Collocation_Methods_for_Uncertainty_Analysis_and_Design/links/53d6abb30cf220632f3dc635.pdf

from chaospy.

jonathf avatar jonathf commented on August 18, 2024

I consider the issue as resolved.

If you consider that not to be the case, or if there are other problems related to the same issue, feel free to re-open the issue.

from chaospy.

robertsawko avatar robertsawko commented on August 18, 2024

Yes, Jonathan. Thanks a lot for your help here - the discussion was very useful to me. I should closed it before actually.

from chaospy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.