Piecewise Transformation of Distribution

Can we use openturns to apply a piecewise transform to a distribution?
e.g. X\sim \operatorname{Uniform}(0,1) with transform:

m(X) = \begin{cases} 5X & \textrm{ if } 0 < X \leq 0.9; \\ 0.9 \times X + 3.69 & \textrm{ if } 0.9 < X \leq 1. \end{cases}
1 Like

Yes, you can do that with the following code:

import openturns as ot
unif = ot.Uniform(0.0, 1.0)
f = ot.SymbolicFunction("x", "if (x <= 0.9, 5 * x, 0.9 * x + 3.69)")
transformed = ot.CompositeDistribution(f, unif)

Now draw the CDF of the transformed distribution:

transformed.drawCDF()

CDF of the transformed distribution

3 Likes

This is awesome! I’m thrilled that this package has solved quite a few of my probability modeling problems. Perhaps it’s due to the name, but I believe there’s no reason OpenTURNS shouldn’t be widely recognized, especially with such a friendly community. Spread it!

3 Likes