R/KLdivmix.R

Defines functions KLdivmix

## Kullback-Leibler distance between mixtures
KLdivmix <- function(mixRef, mixTest) {
    interval <- support(mixRef)
    if(!all(interval == support(mixRef)))
        warning("Support of mixRef and mixTest do not match.")
    ## note: setting stop.on.error to FALSE manages to avoid boundary
    ## value issues
    integrate(function(x) { dmix(mixRef, x) * (dmix(mixRef,x,log=TRUE) - dmix(mixTest,x,log=TRUE)) }, interval[1], interval[2], stop.on.error=FALSE )$value
}

Try the RBesT package in your browser

Any scripts or data that you put into this service are public.

RBesT documentation built on Aug. 22, 2023, 1:08 a.m.