开发者

pdf of a particular distribution

开发者 https://www.devze.com 2023-03-31 04:11 出处:网络
I am new to Matlab. I would like to check the so call \"logarithmic law\" for determinant of random matrices with Matlab, but still do not know how.

I am new to Matlab. I would like to check the so call "logarithmic law" for determinant of random matrices with Matlab, but still do not know how.

Logarithmic law:

Let A be a random Bernoulli matrix (entries are iid, taking value +-1 with prob. 1/2) of size n by n. We may want to compare the probability density function of (log(det(A^2))-log(factorial(n-1)))/sqrt(2n) with the pdf of Gaussian distribution. The logarithmic law says that the pdf of the first will approach to that of the second when n approaches infinity.

My Matlab task is very simple: check the comparison for, say n=100. Anyone knows how to do so?

开发者_JAVA技巧

Thanks.


Consider the following experiment:

n = 100;                           %# matrix size
num = 1000;                        %# number of matrices to generate

detA2ln = zeros(num,1);
for i=1:num
    A = randi([0 1],[n n])*2 - 1;  %# -1,+1
    detA2ln(i) = log(det(A^2));
end

%# `gammaln(n)` is more accurate than `log(factorial(n-1))`
myPDF = ( detA2ln - gammaln(n) ) ./ sqrt(2*log(n));
normplot(myPDF)

pdf of a particular distribution

Note that for large matrices, the determinant of A*A will be too large to represent in double numbers and will return Inf. However we only require the log of the determinant, and there exist other approachs to find this result that keeps the computation in log-scale.

In the comments, @yoda suggested using the eigenvalues detA2(i) = real(sum(log(eig(A^2))));, I also found a submission on FEX that have a similar implementation (using LU or Cholesky decomposition)

0

精彩评论

暂无评论...
验证码 换一张
取 消