Repository navigation
Description
I'm not sure what to do here. I need several pieces of a histogram copula but I don't want to publicly support a proper HistogramCopula and coming up with an api for that, at least not now.
Currently the pieces that I need are in recipes and tool functions. I needed it for Bernstein distribution or copula and again in a notebook to check quality of rvs (for #7408 ). But using numpy.histogrammdd and the tools function requires work and checking documentation and is not very convenient.
aside: #7444 to convert raw probability grid to have uniform margins.
possible constructor tool methods
from_cdfgrid that's pretty straight forwardfrom_pdfgrid tricky if we have pdf on grid points and not bin probabilities, use case StudentTCopula where we don't have cdf (of binsfrom_datausing np.histogramm_dd we get cell probabilities and the can cumsum for cdf, requires ranks to get uniform margins if nobs is multiple of number of bins.
from_cdf and from_data was used in constructing Bernstein distribution copulas in examples and unit tests.
from_pdf: I wrote distribution.tools.average_grid to compute bin means, but that average grid needs cleaning and transformation to form a proper copula. (e.g. #7408 to get uniform margins). There is still the problem that copula can become unbound at the edges, in examples I stay far enough away from 0, 1 boundaries.
searching for histogram copula finds:
https://rdrr.io/cran/SimCop/man/plot.CopApprox.html
https://rdrr.io/cran/SimCop/man/GetApprox.html
Tajvidi, Nader, and B. A. Turlach. "A general approach to generate random variates for multivariate copulae." Australian & New Zealand Journal of Statistics 60, no. 1 (2018): 140-155.
(only 1 citation)
Activity
josef-pkt commentedon May 12, 2021
The Tajvidi and Turlach refers also to the following for grid sampling
Goodwin, Barry K. 2013. “A Note on a Simplified and General Approach to Simulating from Multivariate Copula Functions.” Applied Economics Letters 20 (9): 910–15. https://doi.org/10.1080/13504851.2012.761418.
Article looks useless to me. Too vague and no details on the method, especially no description about how to do the binning (probabilities for grid).
josef-pkt commentedon May 12, 2021
random sampling from histogram distribution can work the same way as in Bernstein distribution.
sample grid number and then sample uniformly within grid (instead of using Beta distribution conditional on grid number as in Bernstein distribution)
In univariate case using linearly interpolated (piecewise linear) ppf is simpler.
almost forgot:
scipy has (univariate) histogram distribution already for some time
rv_histogramhttps://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.rv_histogram.html