# dp Package¶

Implements some of the MAD-Bayes algorithms by Tamara et al.

## dpmeans Module¶

The DP-means algorithm by Kulis et al.

The DP-means algorithm by Kulis et al.

• $$x$$ : input data, a sequence of length $$N$$
• $$\lambda$$ : cluster penalty parameter
• progress_plots : Scatter plot clusters at every iteration
Returns: Cluster indicator variables

Algorithm:

1. Initialise:
• Number of clusters $$K=1$$
• Global cluster mean $$\mu_1 = \frac{1}{n} \sum_n x_n$$
• Cluster indicator variables $$z_n = 0 \quad \forall n$$
1. Repeat until convergence:
• For each point $$n$$:
• Compute distance to each cluster $$d_{nk} = ||x_n - \mu_k||^2$$
• If $$\min d_{nk} > \lambda$$ then set $$K=K+1, z_n=K, \mu_k=x_n$$
• Otherwise set $$z_n= \arg\!\min_k d_{nk}$$
• For each cluster $$k$$, compute $$\mu_k = \frac{1}{|\{n: z_n = k\}|}\sum_{n: z_n = k} x_n$$