This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m = My_mechanism(10,20,1) | |
# m.animation_vp(0.01,100,400) | |
# m.animation_m() | |
m.animation_m_plus() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from copulalib.copulalib import Copula | |
plt.style.use('ggplot') | |
def generateData(): | |
global x,y | |
x = np.random.normal(size=250) | |
y = 2.5*x + np.random.normal(size=250) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copula class | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from copulalib.copulalib import Copula | |
from scipy.stats import norm | |
plt.style.use('ggplot') | |
class copulaClass(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################################################### | |
# Correlation details: | |
# Correlation index range: [-1,1] [negative,positive] | |
# Kendall's tau: 0.4859437751 | |
# Spearman's rho: 0.665549080785 | |
# Parameter of the copula (theta): 5.48651123047 | |
##################################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
plt.style.use('ggplot') | |
currency_needed = ['EUR','CNY','THB','VND','MYR','KHR','XOF'] | |
country = ['Europe','China','Thailand','Vietnam','Malesia','Cambodia','Senegal'] | |
print('Available currencies:') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x <- read.table("x.txt") | |
y <- read.table("y.txt") | |
mat <- matrix(nrow=100,ncol=2) | |
for(i in 1:100) | |
{ | |
mat[i,1] <- x[,1][i] | |
mat[i,2] <- y[,1][i] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Normal copula | |
normal.cop <- normalCopula(dim=2) | |
fit.cop<- fitCopula(normal.cop,pobs(mat),method="ml") | |
# Coefficients | |
rho <- coef(fit.cop) | |
print(rho) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pseudo observations | |
p_obs <- pobs(mat) | |
plot(p_obs[,1],p_obs[,2],main="Pseudo/simulated observations: BLUE/RED",xlab="u",ylab="v",col="blue") | |
# Simulate data | |
set.seed(100) | |
u1 = rCopula(500,normalCopula(coef(fit.cop),dim=2)) | |
points(u1[,1],u1[,2],col="red") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Plot data with histograms | |
xhist <- hist(mat[,1], breaks=30, plot=FALSE) | |
yhist <- hist(mat[,2], breaks=30, plot=FALSE) | |
top <- max(c(xhist$counts, yhist$counts)) | |
xrange <- c(-4,4) | |
yrange <- c(-6,6) | |
nf <- layout(matrix(c(2,0,1,3),2,2,byrow=TRUE), c(3,1), c(1,3), TRUE) | |
par(mar=c(3,3,1,1)) | |
plot(mat[,1], mat[,2], xlim=xrange, ylim=yrange, xlab="", ylab="") | |
par(mar=c(0,3,1,1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
b = [] | |
for i in range(50): | |
a = np.random.normal(5,i+1,10) | |
b.append(a) | |
c = np.array(b) |