discretizeMap: Discretize a continuous function by a specified level

Usage Arguments Examples

View source: R/discretizeMap.R

Usage

1

Arguments

N
map
xlim

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (N, map, xlim)
{
    x_lower = xlim[1]
    x_upper = xlim[2]
    dx = (x_upper - x_lower)/(N - 1)
    domain = seq(from = x_lower, to = x_upper, by = dx)
    codomain = sapply(X = domain, FUN = function(x) map(x))
    helperMatrix = matrix(codomain, ncol = 1) %*% rep(1, N)
    indices = apply(X = helperMatrix, MARGIN = 1, FUN = function(x) {
        dist = abs(x - domain)
        index = which(dist == min(dist))
        return(index)
    })
    A = matrix(rep(0, N * N), ncol = N, nrow = N)
    for (i in 1:N) {
        A[indices[i], i] = 1
    }
    return(A)
  }

PhilippVWC/myBayes documentation built on Oct. 2, 2020, 8:25 a.m.