R/Gating.R

Defines functions GateLogit

Documented in GateLogit

## Gating Function: Multiple Logit
#' Computes the logit regression weights in log.
#'
#' @param x An N * P covariate matrix, where N is sample size. The first column MUST be 1.
#' @param alpha A g * P matrix. Logit regression coefficients.
#' @return The log of \code{tcrossprod(x,alpha)} with dim N * g, with each row normalized by \code{rowLogSumExps}
#'
#' @keywords internal
#'
#' @export GateLogit
GateLogit = function(x, alpha)
{
  gate.body=tcrossprod(x,alpha)
  return(sweep(gate.body, 1, rowLogSumExps(gate.body), FUN = "-", check.margin = FALSE))
}
sparktseung/LRMoE documentation built on March 21, 2022, 3:22 a.m.