MATLAB: I Just need Code For non-uniform Sampling,Any help

sampling

i got a code for uniform sampling ,but still need a code for non-uniform sampling ?

Best Answer

You can draw numbers from a random sample with weighted probability by using
For example,
population = 1:20;
k = 10; %draw 10 samples from the population
w = linspace(0,1,numel(population)); % the probability of drawing each element in the population
y = randsample(population,k,true,w)
Or you could draw random numbers from a normal distribution using X = randn(n).
For example, this line below draws 20 random values from a normal distribution centered at 7 with standard deviation of 5.
x = 5 * randn(1,20) + 7