Not able to plot probability density distribution.
显示 更早的评论
I am trying to plot a probability density fucntion of growth factors of a matrix with respect to LU decomposition ; the growth factor is defined as g_f in my code.
The final plot should look like this for 3 values of m (size of matrix), I tried it for m = 8. But the plot does not appear! It only gives a nlank figure! Can someone suggest me what changes I shall do, thanks a lot for your advice and time!

x = 1:1000:1;
pd = makedist('Normal');
pd = makedist('Weibull','A',5,'B',2);
n = 1000;
gf = zeros(n);
for j = 1:n
A = (randi([0,1] , 8));
[L,U] = lu(A);
g_f(j) = max(U)/max(A);
end
pdf_normal = pdf(pd,g_f);
plot(x,pdf_normal,'LineWidth',2)
20 个评论
Anshuman
2022-10-29
Torsten
2022-10-30
It's time that you explain in your own words what you are trying to do.
Your code does not help that much.
@Anshuman Pls check again at your level (It's more subjective rather than Matlab)
x = 0:0.1:2;
pd = makedist('Normal');
%pd = makedist('Weibull','A',5,'B',2);
n=length(x);
gf = zeros(n);
m=[8 16 32];
g_f=zeros(1,n);
for i=1:length(m)
for j = 1:n
A = (randi([0,1],m(i)));
[L,U] = lu(A);
g_f(j) = max(U)/max(A);
end
pdf_normal = pdf(pd,g_f);
plot(x,pdf_normal);
hold on;
end
grid on;
Anshuman
2022-10-30
Anshuman
2022-10-30
Anshuman
2022-10-30
Torsten
2022-10-30
You create a distribution
pd = makedist('Normal');
but you don't use it anywhere. What's the sense of it ?
Anshuman
2022-10-30
Anshuman
2022-10-30
Anshuman
2022-10-30
Instead of
pdf_normal = pdf(pd,g_f);
try
ksdensity(g_f)
n = 10000;
gf = zeros(n);
for j = 1:n
A = (randi([0,1] , 8));
[L,U] = lu(A);
g_f(j) = max(U(:))/max(A(:));
end
ksdensity(g_f)
Anshuman
2022-10-30
Anshuman
2022-10-30
Anshuman
2022-10-30
Anshuman
2022-10-30
Torsten
2022-10-30
I don't know from which kind of distribution the matrix entries in the publication are generated. You choose from a discrete distribution with p(A(i,j) = 0) = p(A(i,j) = 1) = 1/2.
Anshuman
2022-10-30
Torsten
2022-10-30
You also use logarithmic scale for the x-axis. This is not the case in the graphics of the publication.
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Using MATLAB Projects in Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





