Hi all,
If I have 10 kernel estimated densities and I want to draw 10 random numbers at once (one random number from one density), how to do it? I don't want to use for loop because it is slow if I want to repeat this process many times. Here is my code, but it does not work.
%first put 10 kernel densities into an array
X(1,1) = kdensity1;X(2,1) = kdensity2;X(3,1) = kdensity3;X(4,1) = kdensity4;X(5,1) = kdensity5;X(6,1) = kdensity6;X(7,1) = kdensity7;X(8,1) = kdensity8;X(9,1) = kdensity9;X(10,1) = kdensity10;%draw random number
rd = random(X)%error message
Error using prob.TruncatableDistribution/random (line 87)This method requires a scalar probability distribution.
What I want is something similar to this process.
%lambda is 10x1
%gamma is 10x1
%draw random numbers
rd=wblrnd(lambda,gamma); %I get 10 random values at once, and they are from Weibull distributions with different lambdas and gammas
Many thanks in advance
JW
Best Answer