close all
t=linspace(-4,4,1000);
pdf=normpdf(t)
cdf=normcdf(t)
plot(t,pdf,"b",'LineWidth', 2);
hold on
plot(t,cdf,'k','LineWidth', 3);
N=5
y=rand(N,1);
x=zeros(N,1)-4;
scatter(x,y,60,'r','filled')
% 绘制随机数的直方图
title('标准正态分布');
xlabel('值');
ylabel('概率密度');
x2=norminv(y);
y2=zeros(N,1);
scatter(x2,y2,80,'*')
p=gca().Position
for i=1:N
xx3=p(1)+p(3)*(x2(i)+4)/8
yy3=p(2)+p(4)*y(i)/1.5;
x3=[p(1),xx3];
y3=[yy3,yy3];
arrow=annotation('textarrow',x3,y3,'Color','red')
x4=[xx3,xx3]
y4=[ yy3 p(2)]
arrow=annotation('textarrow',x4,y4,'Color','red')
%
% set(arrow, 'LineColor', 'r'); % 设置为红色
end
legend('密度函数f(t)','累计分布F(t)',"[0,1]均匀分布");
ylim([0,1.5])
xlim([-4,4])
hold off
标签:xx3,cdf,yy3,画图,箭头,matlab,arrow,x2
From: https://www.cnblogs.com/redufa/p/18421300