`totalmerge`

Total-merge algorithm for estimation of mixture model structure and parameters, with generalized internal estimations. This function is run after running a function like smem or totalsplit

**Syntax**

[theta, D, info, options] = totalmerge(data, theta0, target_num, options)

**Description**

This function implements the total-merge algorithm -- It is for merging candidates based on certain criteria to get the final results for different number of components

`totalmerge(data, theta0, target_num, options)` estimates and saves parameters and the mixture distributions `D` from number of components in `theta0` to `target_num` components,fitted to `data`. It can also return the last merge stage Point: If info for all merges is needed one should do only one merge

For information about the output `theta`, see Distribution Parameters Structure. The input argument `data` is described in Data Input Argument to Functions. You may also want to read about `options` or `info` arguments.

**Available Options**

This function supports all the options described in estimation options. This function accepts the following additional fields in `options.sm`:

(default`tolCostDiff``0`) : Minimum decrease in cost to accept a split.(default`numMax``2*target_num`) : Maximum number of mixture components.(default MVN distribution) : distribution structure defining the mixture component distribution type.`componentD`(default result) : folder to save the results for different components -- the files are called tmerge%i where %i is number of components`savefoler`

`options.inner` can be used to set specific options for the inner estimations. To set options only for the partial or full inner estimations use `options.inner.partial` or `options.inner.full` respectively.

**References**

- S. Sra, R. Hosseini, L. Theis, and M. Bethge, “Data modeling with the elliptical gamma distribution,” in Proceedings of the Eighteenth International Conference on Artificial Intelligence and Statistics, 2015, pp. 903–911.