File: t_DistributionTransformation_std.py

package info (click to toggle)
openturns 1.26-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 67,708 kB
  • sloc: cpp: 261,605; python: 67,030; ansic: 4,378; javascript: 406; sh: 185; xml: 164; makefile: 101
file content (40 lines) | stat: -rwxr-xr-x 1,236 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /usr/bin/env python

import openturns as ot

# ot.Log.Show(ot.Log.ALL)

coll = []

# case 1: no transformation
coll.append([ot.Normal(), ot.Normal()])

# case 2: same copula
left = ot.JointDistribution([ot.Normal(), ot.Gumbel()], ot.IndependentCopula(2))
right = ot.JointDistribution([ot.Triangular()] * 2, ot.IndependentCopula(2))
coll.append([left, right])

# case 3: same standard space
left = ot.JointDistribution([ot.Normal(), ot.Gumbel()], ot.IndependentCopula(2))
right = ot.JointDistribution([ot.Triangular()] * 2, ot.GumbelCopula())
coll.append([left, right])

# TODO case 4: different standard space

for left, right in coll:
    transformation = ot.DistributionTransformation(left, right)
    print("left=", left)
    print("right=", right)
    print("transformation=", transformation)
    inverseTransformation = transformation.inverse()
    print("inverseTransformation=", inverseTransformation)
    print("-" * 100)

# with marginaltransformation
copula = ot.BlockIndependentCopula([ot.IndependentCopula(2), ot.IndependentCopula(2)])
distribution = ot.JointDistribution([ot.Normal()] * 4, copula)
print(
    ot.DistributionTransformation(
        ot.IndependentCopula(4), distribution.getMarginal([3, 1, 2, 0])
    )
)