Generation

generate functionSat, 22 Jul 2023

loops through sequential subsets of a binary vector and randomly changes 1s to 0 until the mean of each subset is below 0.40.

b <- c(1,1,1,1,1,1,1,0,0,0,0,0,0,0) while (mean(b) > 0.40) { b[sample(which(b==1), 1)] <- 0 }

Questions about programming?Chat with your personal AI assistant