You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a problem when I want to generate random samples and also to calculate the "pdf" and the "cdf" of the independent copula and the Fréchet–Hoeffding bounds. I know that densities for the bounds do not exist, however the cumulative function should be able to be calculated. In the first code I show a small example where it works well for the Gaussian copula. It involves generating a 3D graph of the density and cumulative function of the copula. To change between density and cumulative function it is only necessary to comment and uncomment
using Copulas, Distributions, Plotly
###Define a valid correlation matrix for the bivariate Gaussian copula
Σ = [1.00.5; 0.51.0] # example###Create the bivariate Gaussian copula with the correlation matrix Σ
G =GaussianCopula(Σ)
#G = IndependentCopula(2)#G = MCopula(2)###Generate a grid of two-dimensional values (u, v) in [0, 1]x[0, 1]
u =range(0, stop=1, length=100)
v =range(0, stop=1, length=100)
grid = [(ui, vi) for ui in u, vi in v]
###Calculate the cumulative function or density of the copula in the grid matrix
density =zeros(length(grid))
###acumulate = zeros(length(grid))for (i, (ui, vi)) inenumerate(grid)
###acumulate[i] = cdf(G, [ui, vi])
density[i] =pdf(G, [ui, vi])
end####Reformat the density into a two-dimensional array
z_data =reshape(density, 100, 100)
layout =Layout(
title="Gaussian Copula",
autosize=false,
scene_camera_eye=attr(x=1.87, y=0.88, z=-0.64),
width=500, height=500,
margin=attr(l=65, r=50, b=65, t=90)
)
plot(surface(
z=z_data,
contours_z=attr(
show=true,
usecolormap=true,
highlightcolor="limegreen",
project_z=true
)
), layout)
The second code is a little more basic, it simply consists of simulating random samples of the independent copula and the Fréchet–Hoeffding bounds. Now, as you can notice, when simulating the Gaussian copula I have no problems, however for the independent copula I get the error
" MethodError: no method matching Random.Sampler(::Type{Random.TaskLocalRNG}, :Random.SamplerType{IndependentCopula{2}}, ::Val{1})"
##########################
using Copulas, Distributions
###Gaussian copula simulation
Σ = [1.00.5; 0.51.0]
G =GaussianCopula(Σ)
simu1 =rand(G,1)
###independent copula simulation
I =IndependentCopula(2)
simu2 =rand(I,1) #Does not generate samples and gives the mentioned error###Mcopula simulation
M =MCopula(2)
simu3 =rand(M,1)
###WCopula simulation
W = Copulas.WCopula(2)
simu4 =rand(W,1)
###########################
The code does not generate samples of the independent copula, nor does it generate samples of "WCopula(2)" since an error of the type "UndefVarError: WCopula not defined" appears. I could solve it by changing "WCopula(2) for Copulas.WCopula(2) )" . However, the error of independent copulation continues. For "MCopula()" and the other elliptic and Archimedean copulas it works well.
Thank you very much for your attention and I look forward to your prompt response.
The text was updated successfully, but these errors were encountered:
Thanks a lot for taking the time to write the details of your issues.
I fixed the problem for sampling the IndependantCopula (a pair of parentheses was missing…) and the WCopula (I had a typo export Wcopula instead of export WCopula…). I also added a fast route for computation of the CDF and PDF of the independent copula, and fixed the implementation of the CDF of MCopula.
I could not install Plotly and thus was not able to run your graph, but all the errors you mention should be gone as soon as the new modifications are released.
EDIT: It got released as v0.1.11 in the registry. Tell me if you still experience these issues on the new version, and if everything is alright we'll close this.
I used the mods in the package and now everything works perfectly. It couples very well with "Ploty" and can effectively obtain samples for the aforementioned copulations. Furthermore, the PDF and CDF functions for the independent copula and the CDF function for the Fréchet–Hoeffding bounds can be perfectly evaluated.
Hello, nice to talk to you.
I have a problem when I want to generate random samples and also to calculate the "pdf" and the "cdf" of the independent copula and the Fréchet–Hoeffding bounds. I know that densities for the bounds do not exist, however the cumulative function should be able to be calculated. In the first code I show a small example where it works well for the Gaussian copula. It involves generating a 3D graph of the density and cumulative function of the copula. To change between density and cumulative function it is only necessary to comment and uncomment
####################################################################
###############################################################################
The second code is a little more basic, it simply consists of simulating random samples of the independent copula and the Fréchet–Hoeffding bounds. Now, as you can notice, when simulating the Gaussian copula I have no problems, however for the independent copula I get the error
" MethodError: no method matching Random.Sampler(::Type{Random.TaskLocalRNG}, :Random.SamplerType{IndependentCopula{2}}, ::Val{1})"
##########################
###########################
The code does not generate samples of the independent copula, nor does it generate samples of "WCopula(2)" since an error of the type "UndefVarError: WCopula not defined" appears. I could solve it by changing "WCopula(2) for Copulas.WCopula(2) )" . However, the error of independent copulation continues. For "MCopula()" and the other elliptic and Archimedean copulas it works well.
Thank you very much for your attention and I look forward to your prompt response.
The text was updated successfully, but these errors were encountered: