I want to create an n row by 40 column array of zeroes and 1's representing values of 20 bi-allelic genetic loci, with the 1's randomly assigned to the 40 possible locations (columns).. But I need to have the total number of 1's be no greater than min and no greater than max. For example, suppose I want the mean number of 1's to be 12 (30% of the 40 total alleles) but I want the number to be a least 10 and at most 14. Simply darwing a uniform random on [0,1] wiht probability of success = 0.3 will not work, as individual row may have fewer than min 1's or more than max 1's.
MATLAB: Sampling to obtain number of successes within an interval
sample from an interval
Related Question
- How to generate matrices that satisfies constraints on sum of row elements and sum of column elements
- Trim Matrix and find the min-max value the reshaped matrix
- How to count data based on the categories
- How to set the colorbar to have a limited number of colors
- Count the Number of Times a Specific String Occurs in a given Column
- Conditional Random number generation
Best Answer