Skip to content

Instantly share code, notes, and snippets.

@CerebralMastication
Created February 14, 2018 03:56
Show Gist options
  • Save CerebralMastication/489e0c728dcdca398cebd043b9866669 to your computer and use it in GitHub Desktop.
Save CerebralMastication/489e0c728dcdca398cebd043b9866669 to your computer and use it in GitHub Desktop.
r example using random numbers
require(tictoc)
tic()
# create a 250 col x 80000 row matrix of random uniform (0,1) numbers
random_numbers <- matrix( runif(250 * 80000), ncol=250)
#square root of the random numbers
sqrt_random_numbers <- sqrt(random_numbers)
#mean of each column
column_means <- colMeans(sqrt_random_numbers)
# create a random index of 80000 values between 1 and 80000 then get the data from sqrt_random_numbers
# from the 4th column and put that all in a vector
resample_index <- sample(1:80000, 80000, replace=T)
## pulls the item from the 4th column of the squared matrix that correspond to the resampled index
resorted_4th_column <- sqrt_random_numbers[ resample_index ,4 ]
toc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment