Changed behavior of log(gamma(x))
This commit is contained in:
parent
27a296ad00
commit
002c0db3f9
4 changed files with 35 additions and 6 deletions
|
|
@ -1,3 +1,5 @@
|
|||
# Generated by roxygen2: do not edit by hand
|
||||
|
||||
export(admix1)
|
||||
export(calculatePopLogml)
|
||||
export(learn_simple_partition)
|
||||
|
|
|
|||
|
|
@ -4,16 +4,17 @@
|
|||
#' for the mean parameter.
|
||||
#' @param points points
|
||||
#' @param fii fii
|
||||
#' @export
|
||||
calculatePopLogml <- function(points, fii) {
|
||||
n <- length(points)
|
||||
fuzzy_ones <- sum(points)
|
||||
fuzzy_zeros <- n - fuzzy_ones
|
||||
val = log(gamma(1)) -
|
||||
log(gamma(1 + n / fii)) +
|
||||
log(gamma(0.5 + fuzzy_ones / fii)) +
|
||||
log(gamma(0.5 + fuzzy_zeros / fii)) -
|
||||
log(gamma(0.5)) -
|
||||
log(gamma(0.5))
|
||||
val <- log_gamma(1) -
|
||||
log_gamma(1 + n / fii) +
|
||||
log_gamma(0.5 + fuzzy_ones / fii) +
|
||||
log_gamma(0.5 + fuzzy_zeros / fii) -
|
||||
log_gamma(0.5) -
|
||||
log_gamma(0.5)
|
||||
return(val)
|
||||
}
|
||||
|
||||
|
|
|
|||
8
R/log_gamma.R
Normal file
8
R/log_gamma.R
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#' @title Log Gamma
|
||||
#' @description Equal to log(gamma(x)) with special handling of x < 0 for
|
||||
#' Matlab compatibility
|
||||
#' @param x number
|
||||
#' @return log(gamma(x)) for x > 0, Inf otherwise
|
||||
log_gamma <- function(x) {
|
||||
ifelse(x > 0, log(gamma(x)), Inf)
|
||||
}
|
||||
18
man/log_gamma.Rd
Normal file
18
man/log_gamma.Rd
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/log_gamma.R
|
||||
\name{log_gamma}
|
||||
\alias{log_gamma}
|
||||
\title{Log Gamma}
|
||||
\usage{
|
||||
log_gamma(x)
|
||||
}
|
||||
\arguments{
|
||||
\item{x}{number}
|
||||
}
|
||||
\value{
|
||||
log(gamma(x)) for x > 0, Inf otherwise
|
||||
}
|
||||
\description{
|
||||
Equal to log(gamma(x)) with special handling of x < 0 for
|
||||
Matlab compatibility
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue