Google Answers Logo
View Question
 
Q: C. H. Sim Method of Gamma Random Variable Generation in MATLAB ( No Answer,   10 Comments )
Question  
Subject: C. H. Sim Method of Gamma Random Variable Generation in MATLAB
Category: Science
Asked by: chishmishdeez-ga
List Price: $10.00
Posted: 17 Feb 2006 15:22 PST
Expires: 19 Mar 2006 15:22 PST
Question ID: 447099
hi

I am working on project which requires Gamma RV generation. I need to
use C. H. Sim method of RV Generation.
Reference:

C. H. Sim "Generation of Poisson and Gamma Random Vectors with given
marginal and covariance matrix:
Journal of statistical Computation and simulation
Volume 47. no 1-2 Page 1-10 1993

i am wonding if has anyone tried this method and can provide me with a
code. I tried but seems to be wrong. I would appreciate if someone can
help with a code.

thanks
dhiraj
Answer  
There is no answer at this time.

Comments  
Subject: Re: C. H. Sim Method of Gamma Random Variable Generation in MATLAB
From: omidd-ga on 20 Feb 2006 01:18 PST
 
Hi chishmishdeez,

I have no access to the paper you mentioned, but I read a paper
entitled "Simulation of Nakagami Fading Channels With Arbitrary
Cross-Correlation and Fading Parameters" and used the equations
provided there (driven from Sim's method)for generating Gamma
vairates, and it worked.

By the way, may I know where you are from, your nick name seems to be
written in Pingilish!!
Subject: Re: C. H. Sim Method of Gamma Random Variable Generation in MATLAB
From: chishmishdeez-ga on 20 Feb 2006 11:32 PST
 
hi
yes i am talking about the same paper.
did that method work for first example they have given ?

thanks
Dhiraj
Subject: Re: C. H. Sim Method of Gamma Random Variable Generation in MATLAB
From: chishmishdeez-ga on 21 Feb 2006 14:01 PST
 
i Checked my code from few pplz they didnt find any bug
i dont know where i am wrong

How did u approach
Subject: Re: C. H. Sim Method of Gamma Random Variable Generation in MATLAB
From: omidd-ga on 23 Feb 2006 01:30 PST
 
What example you mean? There is just one example in which the Sim's
method used (that with deferent m-parameters) If you mean the first
verification example with m=2.18, the correlation coefficient matrix
in this case dose not satisfy the constraints for the Sim's method
given in (21) , (22) just before verification section, so it can't be
used for that.
If it is not your problem, may I know what is wrong with your results?
Subject: Re: C. H. Sim Method of Gamma Random Variable Generation in MATLAB
From: chishmishdeez-ga on 23 Feb 2006 06:01 PST
 
The Problem is although my code is correct, it is not able to generate
Gamma Vectors of proper statistical properties.i asked my friends to
check the implementation of Sim method but there is no problem.I dont
know where the problem lies.
Subject: Re: C. H. Sim Method of Gamma Random Variable Generation in MATLAB
From: omidd-ga on 26 Feb 2006 00:12 PST
 
Make sure that you are using the cross-covariance matrix in computing
the value a(i,j) of the matrix A, not the correlation coefficients
matrix. Notice that to compute a(i,j) from the recursive equation of
(19c), just previously computed element of i=2:N and j=2:i (N=number
of variates) are needed (the first column of A is computed by 19(b)).
Don't try to compute the others.
Hope this works; otherwise I can give you my code.
Subject: Re: C. H. Sim Method of Gamma Random Variable Generation in MATLAB
From: chishmishdeez-ga on 27 Feb 2006 07:38 PST
 
Hi
let me thank you for ur support.
let me check my code as per your instructions. and try one more time
whats happening. else i will contact you again
Thanks a lot
Dhiraj
Subject: Re: C. H. Sim Method of Gamma Random Variable Generation in MATLAB
From: chishmishdeez-ga on 08 Mar 2006 13:49 PST
 
hi
i would appreciate if u can send me ur code. 
thanks
DHiraj
Subject: Re: C. H. Sim Method of Gamma Random Variable Generation in MATLAB
From: omidd-ga on 10 Mar 2006 23:02 PST
 
Here is the code:

function Na = nakarnd(M, P, R, n);
% M:    m-parameter vector
% P:    power vector
% R:    correlation coefficient matrix
% n:    number of random variable samples

N = length(P);      % Number of variates
var = P.^2 ./ M;    % Variance of variates
covar = sqrt(diag(var)) * R * sqrt(diag(var));  % covariance matrix of variates.
l = M ./ P;     % lambda(i) = m(i)/P(i)
alpha = (1 ./ l') * l;   % alpha(i,j) = l(j) / l(i)
a = zeros(size(covar));
Mg = zeros(1,N);
Mg(1) = M(1);
a(:,1) = (l(1) * l .* covar(1,:))';     % a(i,1) = lambda(1)*lambda(i)*C(1,i)
for i = 2:N
    for j = 2:i
        s = 0;
        for k = 1: j-1
            s = s + a(i,k) * a(j,k) / Mg(k);
        end;
        a(i,j) = l(i) * l(j) * covar(i,j) - s;
        s = 0;
        for k = 1: i-1
            s = s + a(i,k);
        end;
        Mg(i) = M(i) - s;
    end;
end;
Pg = Mg * diag(1 ./ l);     % Pg(i) = Mg(i)./l(i)
g = zeros(n,N);
for j = 1:N;
    %   Each column of G contains samples of one variate.
    g(:,j) = gamrnd(Mg(j),Pg(j)/Mg(j),[n 1]);
end;
b = zeros(n,N,N);
s = zeros(n,1);
Gamma = zeros(n,N);
Gamma(:,1) = g(:,1);
for i = 2:N
    s = zeros(n,1);
    for j = 1:i-1
        %   b, Beta RVs container, is a 3D array with each (vertical) vector at
        % coordinations i,j (indicating length and width offset) contains samples
        % of a variate in its height. Note that b is computed for 1 <= j < i < N

        b(:,i,j) = betarnd(a(i,j),Mg(j)-a(i,j),[n 1]);  % b[ij] samples
        if j < i
            s = s + alpha(i,j) * b(:,i,j) .* g(:,j);
        end;
    end;
    Gamma(:,i) = g(:,i) + s;
end;
Na = sqrt(Gamma);

Hope it resolvoes your problem.
Subject: Re: C. H. Sim Method of Gamma Random Variable Generation in MATLAB
From: chishmishdeez-ga on 13 Mar 2006 06:32 PST
 
thank you
i will compare my code n see where i am going wrong. 
thanks again
Dhiraj

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy