# Path: bmlingam/utils/usr_distrib.py
# def usr_distrib(dist_name, query, param=None, rng=None):
# def _pdf_dblexp(mu, cov, xs):
# def _rnd_dblexp(mu, cov, rng, n_samples):
# def _krt_dblexp(mu, cov):
# def _pdf_mixdblexp(props, mus, covs, xs):
# def _rnd_mixdblexp(props, mus, covs, rng, n_samples):
# def _krt_mixdblexp(props, mus, covs):
# def _pdf_mixnorm(props, mus, covs, xs):
# def _rnd_mixnorm(props, mus, covs, rng, n_samples):
# def _krt_mixnorm(props, mus, covs):
# def rnd_discrete(props, rng, n_samples):
# def wrap_array(x):


import collections
import numpy as np
from itertools import chain
from parse import parse
from bmlingam.utils import dist_names, usr_distrib
    @fix_causality.setter
    def fix_causality(self, value):
        self._fix_causality = value

    @property
    def seed(self):
        return self._seed

    @seed.setter
    def seed(self, value):
        self._seed = value

def _gen_usr_distrib(size, dists, rng):
    """Generate random samples from usr_distrib.
    """
    flt = lambda l: list(chain.from_iterable(l))
    dist_names_local = flt([_dist_name_table[k] for k in dists])

    # Check size
    if isinstance(size, collections.Iterable):
        n_samples, n_dim = (size[0], 1) if len(size) == 1 else size
    else:
        n_samples, n_dim = (size, 1)

    # Select distributions
    ixs_dist = rng.randint(0, len(dist_names_local), n_dim)
    dists = [dist_names_local[ix_dist] for ix_dist in ixs_dist]

    # Generate samples and normalize
    xs_ = np.vstack(

# Path: bmlingam/utils/usr_distrib.py
# def usr_distrib(dist_name, query, param=None, rng=None):
# def _pdf_dblexp(mu, cov, xs):
# def _rnd_dblexp(mu, cov, rng, n_samples):
# def _krt_dblexp(mu, cov):
# def _pdf_mixdblexp(props, mus, covs, xs):
# def _rnd_mixdblexp(props, mus, covs, rng, n_samples):
# def _krt_mixdblexp(props, mus, covs):
# def _pdf_mixnorm(props, mus, covs, xs):
# def _rnd_mixnorm(props, mus, covs, rng, n_samples):
# def _krt_mixnorm(props, mus, covs):
# def rnd_discrete(props, rng, n_samples):
# def wrap_array(x):


# Path: bmlingam/utils/gendata.py
import collections
import numpy as np
from itertools import chain
from parse import parse
from bmlingam.utils import dist_names, usr_distrib

    @fix_causality.setter
    def fix_causality(self, value):
        self._fix_causality = value

    @property
    def seed(self):
        return self._seed

    @seed.setter
    def seed(self, value):
        self._seed = value

def _gen_usr_distrib(size, dists, rng):
    """Generate random samples from usr_distrib.
    """
    flt = lambda l: list(chain.from_iterable(l))
    dist_names_local = flt([_dist_name_table[k] for k in dists])

    # Check size
    if isinstance(size, collections.Iterable):
        n_samples, n_dim = (size[0], 1) if len(size) == 1 else size
    else:
        n_samples, n_dim = (size, 1)

    # Select distributions
    ixs_dist = rng.randint(0, len(dist_names_local), n_dim)
    dists = [dist_names_local[ix_dist] for ix_dist in ixs_dist]

    # Generate samples and normalize
    xs_ = np.vstack(

        [usr_distrib(dist, 'rnd', n_samples, rng) for dist in dists]).T