compactem.core package
Package for the core sampling and optimization related codes.
Submodules
compactem.core.dp module
- generic_blackwell_macqueen_sampler(alpha, sample_size)
Not specific to any base distribution, this just returns how many points from a cluster is needed, using the Blackwell-Macqueen Urn scheme or Polya urn scheme. Essentially, this is partition on the set of natural number a Dirichlet Process achieves.
- Parameters
alpha – the Dirichlet Process concentration parameter
sample_size – num points to be sampled
- Returns
list with entries as number of points in a cluster; len of this list is the number of clusters.
- sample_beta(prior_for_a_beta_A, prior_for_a_beta_B, prior_for_b_beta_A, prior_for_b_beta_B, sample_size, scale_a=1.0, scale_b=1.0)
Given a particular setting of the priors (which also happen to be betas), return parameters of a standard beta distribution.Shape parameters to be sampled - a,b - come from beta(prior_for_a_beta_A, prior_for_a_beta_B) and beta(prior_for_b_beta_A, prior_for_b_beta_B) respectively.
- Parameters
prior_for_a_beta_A – Beta shape parameter A for the prior to use to sample a
prior_for_a_beta_B – Beta shape parameter B for the prior to use to sample a
prior_for_b_beta_A – Beta shape parameter A for the prior to use to sample b
prior_for_b_beta_B – Beta shape parameter B for the prior to use to sample b
sample_size – number of standard beta distributions to be sampled
scale_a – scaling factor for a
scale_b – scaling factor for b
- Returns
list of tuples of the form (a,b), where a,b are parameters of betas. length of list = sample_size