minimum function for two random variables in openturns

Question:

I have big formula containing random variables. at some part of this formula I have to calculate min(X,Y), where X and Y are distributed normally and independently. Finally, after many summations and multiplications I am getting some distribution for which I am drawing its PDF.

I am interested if there is any openturns way to calculate min(X,Y) and plug it into some big formula.

I went through the documentation and discovered the function which calculates expected value of min(X,Y) but not the whole distribution.

Any kind of help will be appreciated.

Asked By: Nika Tsereteli

||

Answers:

It is a little finicky, but it can be done with the MaximumDistribution class.

Let us create 2 independent normal distributions for X and Y, like you suggest:

import openturns as ot
distX = ot.Normal(5.0, 1.0)
distY = ot.Normal(5.0, 1.0)

We start by computing the distributions of -X and -Y:

opposite = ot.SymbolicFunction('x', '-x')
dist_minusX = ot.CompositeDistribution(opposite, distX)
dist_minusY = ot.CompositeDistribution(opposite, distY)

We then compute the distribution of max(-X, -Y):

dist_max_opposites = ot.MaximumDistribution([dist_minusX, dist_minusY])

Since max(-X, -Y) = – min(X, Y), we can get the distribution of min(X, Y) with:

dist_min = ot.CompositeDistribution(opposite, dist_max_opposites)
Answered By: josephmure

Nice trick. You can get the same result using the algebra of independent random variables, which leads to a more straightforward expression and a more efficient resulting distribution:

import openturns as ot
distX = ot.Normal(5.0, 1.0)
distY = ot.Normal(5.0, 1.0)
dist_min = -ot.MaximumDistribution([-distX, -distY])
Answered By: Régis LEBRUN
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.