File: t_CopulaInferenceAnalysis_std.py

package info (click to toggle)
persalys 19.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 46,900 kB
  • sloc: xml: 97,263; cpp: 61,701; python: 4,109; sh: 397; makefile: 84
file content (48 lines) | stat: -rwxr-xr-x 1,243 bytes parent folder | download
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
#! /usr/bin/env python

import openturns as ot
import openturns.testing
import persalys
import os

myStudy = persalys.Study("myStudy")

# Model
filename = "data2.csv"
ot.RandomGenerator.SetSeed(0)
R = ot.CorrelationMatrix(4)
R[0, 3] = 0.9
distribution = ot.JointDistribution([ot.Normal(), ot.Normal(), ot.Normal(), ot.Gumbel()], ot.NormalCopula(R))
sample = distribution.getSample(300)
sample.setDescription(["X0", "X1", "X2", "X3"])
sample.exportToCSVFile(filename, ",")
columns = [0, 2, 3]

model = persalys.DataModel("myDataModel", "data2.csv", columns)
myStudy.add(model)
print(model)

# Dependencies inference analysis ##
analysis = persalys.CopulaInferenceAnalysis("analysis", model)
variables = ["X0", "X3"]
factories = [ot.ClaytonCopulaFactory(),
             ot.FrankCopulaFactory(),
             ot.GumbelCopulaFactory(),
             ot.NormalCopulaFactory(),
             ot.StudentCopulaFactory()]
analysis.setDistributionsFactories(variables, factories)
myStudy.add(analysis)
print(analysis)

analysis.run()

result = analysis.getResult()
inferenceSet = result.getCopulaInferenceSetResult(variables)
print(inferenceSet.getBICResults())

# script
script = myStudy.getPythonScript()
print(script)
exec(script)

os.remove(filename)