I'm trying to simulate ID numbers for population that covers multiple classes with the following parameters Each class assigns IDs sequentially following the same pattern. Each class' ID prefix is different from every other class' prefix. Generate some Example data data(mtcars) set.seed(9999) mtcars$count<-sample(x = 1:100,size = 32,replace=T) mtcars Car.Sample<-sample(1:sum(mtcars$count),15) So,...

I need to select k elements randomly in the range 0 to n-1. n can be upto 10^9. And k can range from 1 to n-1. I can do this in O(n) time just by shuffling an array containing values 0 to n-1 and choosing first k elements from it....

I simulate an evolving population in Julia. Somewhere in my code I randomly sample (sample weighted by the fitnesses of the individuals) individuals in order to form the next generation. Because the same individual can be sampled several times (sampling with replacement), I have to make that I copy the...

I'm searching for a method or library for java (can be java-8) that is capable of generating a random sample (preferable with a fixed seed for deterministic testing) based on the numbers that make up a boxplot. So imagine having the boxplot: ---------- |-----| | |-----------| ---------- min A avg...

Given the same seed, is there a way to produce the exact same random normal numbers generated in SAS, using the rannor function, in R?

I'm trying to take some random samples from a file and do some operations and then write them to another file. But I'm having trouble writing to a file in the grepLine method which can be found below. Inside the while loop of the grepLine function, I get a blank...

I'd like to draw a sample of items from a list, but I want to set the probability each item is included, not the total number of items to draw (so random.sample() does not work). I get the effect I want with the following code (where p is probability of...

The problem is stated as follows, we have a very large number of items which are traversed through an iterator pattern (which dynamicaly constructs or fetches) the requested item. Due to the number of items being large and thus cannot be kept in memory (as a list for example). What...

I was looking to take a random sample from a sequence by zipping it to a random infinite sequence and doing quickselect on the second element of tuples, but I hit the problem that a sequence initialized with random integers doesn't stay with the same value from the first time...

I have a university graduate database and would like to extract a random sample of data of around 1000 records. I want to ensure the sample is representative of the population so would like to include the same proportions of courses eg I could do this using the following: select...

I would like to create a vector of 10 "words" made of 5 characters that have been randomly generated. e.g c("ASDT","WUIW"...) At the moment I am using the following script but surely there should be a much better way of doing this result = list() for (i in 1:10){ result[i]<-paste(sample(LETTERS,...

I'm attempting to randomly sample lines from a (large) file, while always retaining a set of "header lines". Header lines are always at the top of the file and unlike any other lines, begin with a #. The actual file format I'm dealing with is a VCF, but I've kept...

How can I create a vector x in Matlab that has values between 0.8 and 1.2, randomly sampled from a: 1. Uniform 2. Normal distribution? There are a lot of functions dealing with distributions, but I'm having trouble using them properly....

This is my first ever question, so apologies in advance if I don't follow any of the site's norms! I'm experimenting with R Shiny. I am attempting to make an application that allows someone to customize a lot of the components of different distributions and kernel estimators. Before I go...

This may be a rather complex question so if someone can at least point me in the right direction I can probably figure out the rest on my own. Sample data: dat <- data.frame(A = c(1, 4, 5, 3, NA, 5), B = c(6, 5, NA, 5, 3, 5), C...