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 Comments

I tried doing like this: But the plots are not matching!
pd = makedist('Normal');
%pd = makedist('Weibull','A',5,'B',2);
m = 1000;
gf = zeros(m);
for j = 1:m
A = (randi([1,10] , 8));
[L,U] = lu(A);
g_f(j) = max(abs(U))/max(abs(A));
end
pdf_normal = pdf(pd,g_f);
plot(g_f,pdf_normal,'LineWidth',2)
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;
Okay, sure! Thanks a lot for the help!
But I had to plot this for 1000 such A matrices; and the g_f values will automatically lie in the range [0-10], such that they form a distrbution!
And the probability density plot is of g_f.
You create a distribution
pd = makedist('Normal');
but you don't use it anywhere. What's the sense of it ?
pd = makedist('Normal');
%pd = makedist('Weibull','A',5,'B',2);
m=[8 16 32];
for i=1:length(m)
g_f=zeros(1,1000);
for j = 1:1000
A = (randi([0,1],m(i)));
[L,U] = lu(A);
g_f(j) = max(U)/max(A);
end
pdf_normal = pdf(pd,g_f);
scatter(g_f,pdf_normal);
set(gca,'xscale','log')
set(gca,'yscale','log')
hold on;
end
I think I don't need that distribution part; the values should automatically create a distribution!
I can't understand the y-axis of my origianl plot! What is meant by probability distribution over there!
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)
I got something like this
m=[8 16 32];
for i=1:length(m)
g_f=zeros(1,100000);
for j = 1:100000
A = (randi([0,1],m(i)));
[L,U] = lu(A);
g_f(j) = max(U(:))/max(A(:));
end
%pdf_normal = pdf(pd,g_f);
ksdensity(g_f);
%set(gca,'xscale','log')
%xlim([0 10])
%set(gca,'yscale','log')
hold on;
end
Since you refuse to explain what you are trying to do, I can only blindly guess - and that's the result.
@Torsten, really very sorry! I kind of missed your comment! And thanks a lot for your help and time!
A collection of random matrices has been taken and their growth factor (max(U)/max(A) ; where A = LU) has been plotted as the following: The figure represents the results of LU facotrising 1 million matrices each of dimennsion 8,16 and 32, growth factor has been collected into bins of 0.2 and the resulting data is plotted as a probability density distribution.
Moreover, I am getting somewhat similar plot when increasing the number of matrices from 1000 to 1 millions but not the exact plot! Is it related to the random matrice's entries? I am assuming it to be 0-1.
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.
Yeah, I read the text, they are using it like this: 'A = rand(m(i),m(i))/sqrt(m(i));' Now my current plot after using this looks like the following! Can't understand why it's not matching it exactly! Nevertheless, thanks a lot for your help; I really could not have even came close to plotting this, without the help of you all!
You also use logarithmic scale for the x-axis. This is not the case in the graphics of the publication.

Sign in to comment.

Answers (0)

Categories

Find more on Using MATLAB Projects in Simulink in Help Center and File Exchange

Tags

Asked:

on 29 Oct 2022

Commented:

on 30 Oct 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!