File: t_JointDistribution_large.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 (67 lines) | stat: -rwxr-xr-x 2,093 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#! /usr/bin/env python

import openturns as ot

ot.TESTPREAMBLE()

meanPoint = ot.Point(1)
meanPoint[0] = 1.0
sigma = ot.Point(1)
sigma[0] = 3.0
R = ot.CorrelationMatrix(1)
R[0, 0] = 1.0

# Create a collection of distribution
dimension = 2000
print("Creating a composed distribution of dimension ", dimension)
aCollection = ot.DistributionCollection(dimension, ot.Normal(meanPoint, sigma, R))
for i in range(dimension):
    aCollection[i] = ot.Normal(meanPoint, sigma, R)

# Create a a copula
aCopula = ot.IndependentCopula(dimension)

# Instantiate one distribution object
distribution = ot.JointDistribution(aCollection, aCopula)
print("Distribution created.")

# Is this distribution elliptical ?
print("Elliptical = ", distribution.isElliptical())

# Has this distribution an elliptical copula?
print("Elliptical copula = ", distribution.hasEllipticalCopula())

# Has this distribution an independent copula?
print("Independent copula = ", distribution.hasIndependentCopula())

# Test for sampling
size = 10
anotherSample = distribution.getSample(size)

# Define a point
zero = ot.Point(dimension, 0.0)

# Show PDF and CDF of zero point
zeroPDF = distribution.computePDF(zero)
zeroCDF = distribution.computeCDF(zero)
print(" pdf=%.6f" % zeroPDF, " cdf=%.6f" % zeroCDF)

# Get 95% quantile
quantile = distribution.computeQuantile(0.95)
print("Quantile=", repr(quantile))
print("CDF(quantile)=%.6f" % distribution.computeCDF(quantile))

# Extract a 2-D marginal
indices = [1, 0]
print("indices=", repr(indices))
margins = distribution.getMarginal(indices)
print("margins=", repr(margins))
print("margins PDF=%.6f" % margins.computePDF(ot.Point(2)))
print("margins CDF=%.6f" % margins.computeCDF(ot.Point(2)))
quantile = ot.Point(margins.computeQuantile(0.5))
print("margins quantile=", repr(quantile))
print("margins CDF(qantile)=%.6f" % margins.computeCDF(quantile))
print("margins realization=", repr(margins.getRealization()))
sample = margins.getSample(1000)
print("margins sample mean=", repr(sample.computeMean()))
print("margins sample covariance=", repr(sample.computeCovariance()))