12
$\begingroup$

The function CopulaDistribution can be used with the most well known kernels. I was wondering how I can add a new family of kernels in a way that it works in the same way as the current function. For example as the documentation explains:

CopulaDistribution can be used with such functions as Mean, PDF, and RandomVariate, etc.

Do I need to define all these functions myself or is there a smart way of using the functions which are already defined in Mathematica?

I wonder if anyone has done something similar and would like to share his/her experience on this.

$\endgroup$
3
  • 1
    $\begingroup$ @Szabolcs. Thanks for editing my question. I guess I need to read this page (mathematica.stackexchange.com/editing-help#comment-formatting)? $\endgroup$
    – user371
    Commented Feb 12, 2012 at 13:26
  • $\begingroup$ You can read the guide here, but I myself prefer using the editor toolbar when I can, or keyboard shortcuts (the shortcuts are shown in button tooltips, e.g. selecting a piece of text then pressing ctrl-k to format as code is what I use most often) $\endgroup$
    – Szabolcs
    Commented Feb 12, 2012 at 14:03
  • 1
    $\begingroup$ Could you maybe give a concrete example of what you want to do? $\endgroup$ Commented Feb 12, 2012 at 14:38

2 Answers 2

5
$\begingroup$

The function ProbabilityDistribution allows you to define your own distribution functions that can be used with all distribution-related functions. The following example is from the documentation.

Define a custom probability distribution giving its pdf:

  dD = ProbabilityDistribution[ Piecewise[{{x^2/9, 0 < x <= 3}}], {x, -\[Infinity], \[Infinity]}];

Then you can use the built-in functions CDF, Mean etc with it just like any other built-in distribution function. For example:

  CDF[dD,x]

gives:

cdf

Documentation also contains examples of how construct your own multivariate distributions. There are no specific examples of custom copulas in the documentation but the same principle should apply: you need to use ProbabilityDistribution to define such things in order to be able to use built-in function like CDF, PDF, RandomVariate... with them.

$\endgroup$
5
  • $\begingroup$ thanks I appreciate your point that I can use ProbabilityDistribution to define a new multivariate distribution. However, as far as I can see now, it would not be straightforward to construct new multivariate distributions by changing the marginals (as one can do with CopulaDistribution) for that distribution unless one use functions like TransformedDistribution or alike. Is that right? $\endgroup$
    – user371
    Commented Feb 12, 2012 at 13:13
  • $\begingroup$ @Mikael, you are right; and that's the essential "beauty" of the copula approach/representation. The built-in CopulaDistribution function works with built-in kernels listed in the More Information section; there is not documented mechanism to cosntruct your own kernel and use it as the first argument of the CopulaDistribution function. If these standard copulas are not sufficient for your needs, then you need to use ProbabilityDistribution. Regarding TransformedDistribution I am not sure it allows you to specify the marginal distributions and the copula kernel separately. $\endgroup$
    – kglr
    Commented Feb 12, 2012 at 13:48
  • $\begingroup$ @Mikael, bumped into two related questions in SO: this and this ; and Sasha's answers to both might apply for the case of defining custom copula kernels too. $\endgroup$
    – kglr
    Commented Feb 12, 2012 at 16:03
  • $\begingroup$ ... also in response to a different question in SO, Sjoerd mentions that RandomVariate does not work with custom multivariate distributions created via ProbabilityDistribution. $\endgroup$
    – kglr
    Commented Feb 12, 2012 at 16:13
  • $\begingroup$ Many thanks @kguler indeed for very useful links. Regarding TransformedDistributionI should clarify that I was thinking one could transform the marginal distribution of say X from uniform to an arbitrary distribution, say G, by considering the distribution of G(X) using TransformedDistribution. $\endgroup$
    – user371
    Commented Feb 12, 2012 at 16:36
4
$\begingroup$

The following page contains some tips on enabling custom distributions (i.e. written from scratch without TransformedDisribution or ProbabilityDistribution) for use in CopulaDistribution, RandomVariate, etc: Efficient Generation of Random Variates from a Copula Distribution

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.