Learn R Programming

icamix (version 1.0.6)

ATRANSDENSITY:

Description

A function evaluates density of linearly transformed random vector on a given grid. It is used in processing EMFASTICAALG object to obtain density estimation of the mixture components.

Usage

ATRANSDENSITY(grid, A, f)

Arguments

grid
A matrix whose columns store the grid points.
A
Matrix for the linear transformation.
f
Density function before the linear transformation.

Value

answer
Matrix of the same size as grid, with each element being the evaluated linear transformed density at the corresponding grid point.

Examples

Run this code
## An example that evaluates the 2-D uniform distribution on a linear transformation of [1,3]x[1,3]
## f1ind is the density of the uniform distribution on [1,3]^r
f1ind <- function(grid){# mixture component 1 original signal density function
  n <- ncol(grid)
  r <- nrow(grid)
  answer <- rep(1,n)
  for(i in 1:n){
    for(j in 1:r){
      answer[i] <- answer[i] * (grid[j,i] >= 1 & grid[j,i] <= 3) / 2
    }
  }
  answer
}

A <- matrix(c(6, 9, -12, 15), 2, 2, byrow = FALSE)

gridpoints <- t(as.matrix(expand.grid(seq(-32,12,2),seq(18,80,2))))

f1trans <- ATRANSDENSITY(gridpoints, A, f1ind)

plot(t(gridpoints),col=(f1trans>0))

Run the code above in your browser using DataLab