R/ld_sample_customer_matrix.R

Defines functions ld_sample_customer_matrix

Documented in ld_sample_customer_matrix

#' LD functions are utilized for learning and diagnostic use.
#' @export ld_sample_customer_matrix
#' @param numCustomers number of customers to simulate
#' @param maxT number of timeperiods
#' @param purchaseAtT0 by default sets first column of matrix to 1 
ld_sample_customer_matrix <- function(numCustomers, maxT, purchaseAtT0 = TRUE){
  a <- matrix(nrow = numCustomers, ncol =maxT)
  a <- apply(a, c(1:2), function(x) sample(c(0,1),1))
  if (purchaseAtT0 == TRUE) {
    a[ , 1] <- 1 }
  a
}

Try the CADF package in your browser

Any scripts or data that you put into this service are public.

CADF documentation built on Oct. 31, 2024, 5:08 p.m.