How to make a smoother pdf plot?

Hello,
I am trying to plot X versus it pdf value (Y) using gamma function. the plot i get (Ex#1) is very strange. I want to have a plot like Ex#2. Below is my code so far and i would appreciate any help.
X= [0.78;0.33;0.34;0.12;0.19;0.08;0.13;0.01;0.16;0.1;0.14;0.57;0.6;0.18;0.16;0.62;1.23;0.67;0.43;1.03];
G1=makedist('gamma','a',1.26,'b',0.31);
Y=pdf(G1,X);
plot(X,Y,'LineWidth',2)

Respuestas (1)

Nicholas Galang
Nicholas Galang el 13 de Ag. de 2018

0 votos

Your X values are out of order causing the graph to look strange. If you were to sort those values it will help smooth out the graph.

Preguntada:

el 13 de Ag. de 2018

Respondida:

el 13 de Ag. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by