特定分布的 pdf

发布于 2024-12-01 14:57:06 字数 310 浏览 0 评论 0原文

我是 Matlab 新手。我想用 Matlab 检查随机矩阵行列式的所谓“对数定律”,但仍然不知道如何做。

对数定律:

设 A 为大小为 n × n 的随机伯努利矩阵(条目为独立同分布,取值为 +-1,概率为 1/2)。我们可能想要将 (log(det(A^2))-log(factorial(n-1)))/sqrt(2n) 的概率密度函数与高斯分布的 pdf 进行比较。对数定律表明,当 n 接近无穷大时,第一个的 pdf 将接近第二个的 pdf。

我的 Matlab 任务非常简单:检查比较,假设 n=100。有人知道该怎么做吗?

谢谢。

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?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情未る 2024-12-08 14:57:06

考虑以下实验:

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)

在此处输入图像描述

请注意,对于大型矩阵,A*A 的行列式将太大而无法以双精度数字表示并将返回 Inf。然而,我们只需要行列式的对数,并且存在其他方法来找到这个结果,使计算保持对数规模。

在评论中,@yoda 建议使用特征值 detA2(i) = real(sum(log(eig(A^2))));,我还发现了一个 在具有类似实现的 FEX 上提交(使用 LU 或 Cholesky 分解)

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)

enter image description here

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文