Pdf specific distribution

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

Logarithmic law:

Let A be a random Bernoulli matrix (elements iid taking the value + -1 with probability 1/2) of size n by n. We can compare the probability density function (log (det (A ^ 2)) - log (factorial (n-1))) / sqrt (2n) with the Gaussian pdf distribution. The logarithmic law states that the pdf of the first approaches the first when n tends to infinity.

My Matlab task is very simple: check the comparison, say n = 100. Does anyone know how to do this?

Thanks.

+4
source share
1 answer

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],[nn])*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) 

enter image description here

Note that for large matrices, the determinant A * A will be too large to be represented in double numbers and will return Inf . However, we only need the log of the determinant, and there are other approaches for finding this result, which saves the calculations on a logarithmic scale.

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

+5
source

Source: https://habr.com/ru/post/1369423/


All Articles