Learn R Programming

Emcdf (version 0.1.2)

initF: Initialize threads and split data

Description

This function initializes threads and splits data. Retures an S4 object of class "emcdf_obj" that is ready for parallel computation.

Usage

initF(data, num = 2)

Arguments

data

a numeric matrix stores data. Colunms as variables.

num

an integer specifies number of threads to initialize.

Value

an S4 object of class "emcdf_obj", holding pointer to an C++ object. When passed to function emcdf(), it computes joint CDF with multi-threads.

Details

The input data must be a numeric matrix with variables as columns. The choice of "num" is machine dependent. A reasonable number would be the total number of CPU cores - 1. Call coreNum() to get CPU core number.

Examples

Run this code
# NOT RUN {
n = 10^5
set.seed(123)
x = rnorm(n)
y = rnorm(n)
z = rnorm(n)
data = cbind(x, y, z)

#decide thread number
num = coreNum() - 1

#initialize threads
obj = initF(data, num)

#compute empirical CDF
emcdf(obj, c(0.5, 0.5, 0.5))

# }

Run the code above in your browser using DataLab