防灾数学分享 http://blog.sciencenet.cn/u/fzmath 防灾科技学院数学教研室

博文

概率论中不同参数下的Beta分布概率密度函数图形绘制

已有 1092 次阅读 2024-2-21 14:31 |系统分类:教学心得

不同参数下的Beta分布概率密度函数图形

clear,clc,close all %%%%%%%%%%%%%%%%%%%%%%% a<1,b<1 and a>1,b>1 figure('color','white');hold on %%% 画坐标轴 % M = [-0.1,0]; N = [2.5,0]; arrow2dp(M,N); % x 轴 % hold on % M = [0,-0.1]; N = [0,2.2]; arrow2dp(M,N);% x 轴 text(-0.05,-0.09,'$$O$$','InterPreter','LaTex','FontSize',14) text(-0.11,1.85,'$$f(x)$$','InterPreter','LaTex','FontSize',16) text(1.1,-0.1,'$$x$$','InterPreter','LaTex','FontSize',16) %%% 画概率密度函数 x1 = 0.01:0.01:0.99; y = betapdf(x1,0.6,0.5);plot(x1,y,'b-','LineWidth',1.5); x2 = 0.0:0.01:1;y = betapdf(x2,2,3); plot(x2,y,'r-','LineWidth',1.5) plot([1,1],[0,2.2],'k--','LineWidth',1.2) xlim([-0.1 1.2]); ylim([-0.1 2.1]) ax = gca; ax.Position = [0.1 0.1 0.9 0.9]; ax.FontName = 'times new roman'; ax.FontSize = 14; % 坐标轴移到原点 ax.XAxisLocation = 'origin'; ax.YAxisLocation = 'origin'; % box off % 坐标轴刻度 使用LaTex公式 xticks([0.5,1]); xticklabels({'$0.5$','$1$'}); yticks([0.5,1,1.5,2]); yticklabels({'$0.5$','$1$','$1.5$','$2.0$'}); ax.TickLabelInterpreter = 'latex'; x = [0.35 0.2]; y = [0.9,0.7];  annotation('textarrow',x,y,'String','$\alpha = 0.6<1,\beta = 0.5<1$ ','Interpreter','latex','FontSize',14) x = [0.6 0.54]; y = [0.8,0.7];  annotation('textarrow',x,y,'String','$\alpha = 2>1,\beta = 3>1$ ','Interpreter','latex','FontSize',14) % 图例 使用Latex公式 % h=legend('$\bar{R}(\tau)=A\frac{\sin(\pi B\tau)}{\pi B\tau}\cos(2\pi\tilde{f}\tau)$',... %     '$\hat{S}(\tau)=\pm A\frac{\sin(\pi B\tau)}{\pi B\tau}$',... %     'Interpreter','latex','FontSize',14,... %     'Box','off'); % h.Position = h.Position + [0 -0.06 0 0.06]; % 坐标轴箭头 annotation('arrow',[0.17, 0.17],[0.1, 0.99999],'LineWidth',1.5); annotation('arrow',[0.1, 0.999],[0.142, 0.142],'LineWidth',1.5); %axis equal; %%%%%%%%%%%%%%%%%%%%%%%%% a<1,b>=1 and a>=1,b<1 figure('color','white');hold on %%% 画坐标轴 % M = [-0.1,0]; N = [2.5,0]; arrow2dp(M,N); % x 轴 % hold on % M = [0,-0.1]; N = [0,2.2]; arrow2dp(M,N);% x 轴 text(-0.05,-0.09,'$$O$$','InterPreter','LaTex','FontSize',14) text(-0.11,1.85,'$$f(x)$$','InterPreter','LaTex','FontSize',16) text(1.1,-0.1,'$$x$$','InterPreter','LaTex','FontSize',16) %%% 画概率密度函数 x1 = 0.01:0.01:0.99; y = betapdf(x1,0.8,1.2);plot(x1,y,'b-','LineWidth',1.5); x2 = 0.0:0.01:1;y = betapdf(x2,1.3,0.7); plot(x2,y,'r-','LineWidth',1.5) plot([1,1],[0,2.2],'k--','LineWidth',1.2) xlim([-0.1 1.2]); ylim([-0.1 2.1]) ax = gca; ax.Position = [0.1 0.1 0.9 0.9]; ax.FontName = 'times new roman'; ax.FontSize = 14; % 坐标轴移到原点 ax.XAxisLocation = 'origin'; ax.YAxisLocation = 'origin'; % box off % 坐标轴刻度 使用LaTex公式 xticks([0.5,1]); xticklabels({'$0.5$','$1$'}); yticks([0.5,1,1.5,2]); yticklabels({'$0.5$','$1$','$1.5$','$2.0$'}); ax.TickLabelInterpreter = 'latex'; x = [0.34 0.25]; y = [0.9,0.71];  annotation('textarrow',x,y,'String','$\alpha = 0.8<1,\beta = 1.2>1$ ','Interpreter','latex','FontSize',14) x = [0.68 0.73]; y = [0.78,0.68];  annotation('textarrow',x,y,'String','$\alpha = 1.3>1,\beta = 0.7<1$ ','Interpreter','latex','FontSize',14) % 图例 使用Latex公式 % h=legend('$\bar{R}(\tau)=A\frac{\sin(\pi B\tau)}{\pi B\tau}\cos(2\pi\tilde{f}\tau)$',... %     '$\hat{S}(\tau)=\pm A\frac{\sin(\pi B\tau)}{\pi B\tau}$',... %     'Interpreter','latex','FontSize',14,... %     'Box','off'); % h.Position = h.Position + [0 -0.06 0 0.06]; % 坐标轴箭头 annotation('arrow',[0.17, 0.17],[0.1, 0.99999],'LineWidth',1.5); annotation('arrow',[0.1, 0.999],[0.142, 0.142],'LineWidth',1.5); %axis equal; %%%%%%%%%%%%%%%%%%%% a=1,b>=1 and a>1,b=1 figure('color','white');hold on %%% 画坐标轴 % M = [-0.1,0]; N = [2.5,0]; arrow2dp(M,N); % x 轴 % hold on % M = [0,-0.1]; N = [0,2.2]; arrow2dp(M,N);% x 轴 text(-0.05,-0.09,'$$O$$','InterPreter','LaTex','FontSize',14) text(-0.11,1.85,'$$f(x)$$','InterPreter','LaTex','FontSize',16) text(1.1,-0.1,'$$x$$','InterPreter','LaTex','FontSize',16) %%% 画概率密度函数 x1 = 0.01:0.01:0.99; y = betapdf(x1,1,1.2);plot(x1,y,'b-','LineWidth',1.5); x2 = 0.0:0.01:1;y = betapdf(x2,1.3,1); plot(x2,y,'r-','LineWidth',1.5) plot([1,1],[0,2.2],'k--','LineWidth',1.2) xlim([-0.1 1.2]); ylim([-0.1 2.1]) ax = gca; ax.Position = [0.1 0.1 0.9 0.9]; ax.FontName = 'times new roman'; ax.FontSize = 14; % 坐标轴移到原点 ax.XAxisLocation = 'origin'; ax.YAxisLocation = 'origin'; % box off % 坐标轴刻度 使用LaTex公式 xticks([0.5,1]); xticklabels({'$0.5$','$1$'}); yticks([0.5,1,1.5,2]); yticklabels({'$0.5$','$1$','$1.5$','$2.0$'}); ax.TickLabelInterpreter = 'latex'; x = [0.34 0.25]; y = [0.8,0.62];  annotation('textarrow',x,y,'String','$\alpha = 1,\beta = 1.2>1$ ','Interpreter','latex','FontSize',14) x = [0.68 0.73]; y = [0.68,0.637];  annotation('textarrow',x,y,'String','$\alpha = 1.3>1,\beta =1$ ','Interpreter','latex','FontSize',14) % 图例 使用Latex公式 % h=legend('$\bar{R}(\tau)=A\frac{\sin(\pi B\tau)}{\pi B\tau}\cos(2\pi\tilde{f}\tau)$',... %     '$\hat{S}(\tau)=\pm A\frac{\sin(\pi B\tau)}{\pi B\tau}$',... %     'Interpreter','latex','FontSize',14,... %     'Box','off'); % h.Position = h.Position + [0 -0.06 0 0.06]; % 坐标轴箭头 annotation('arrow',[0.17, 0.17],[0.1, 0.99999],'LineWidth',1.5); annotation('arrow',[0.1, 0.999],[0.142, 0.142],'LineWidth',1.5); %%%%%%%%%%%%%%%%%% a=1,b=1 figure('color','white');hold on %%% 画坐标轴 % M = [-0.1,0]; N = [2.5,0]; arrow2dp(M,N); % x 轴 % hold on % M = [0,-0.1]; N = [0,2.2]; arrow2dp(M,N);% x 轴 text(-0.05,-0.09,'$$O$$','InterPreter','LaTex','FontSize',14) text(-0.11,1.85,'$$f(x)$$','InterPreter','LaTex','FontSize',16) text(1.1,-0.1,'$$x$$','InterPreter','LaTex','FontSize',16) %%% 画概率密度函数 x1 = 0.01:0.01:0.99; y = betapdf(x1,1,1);plot(x1,y,'b-','LineWidth',1.5); plot([1,1],[0,2.2],'k--','LineWidth',1.2) xlim([-0.1 1.2]); ylim([-0.1 2.1]) ax = gca; ax.Position = [0.1 0.1 0.9 0.9]; ax.FontName = 'times new roman'; ax.FontSize = 14; % 坐标轴移到原点 ax.XAxisLocation = 'origin'; ax.YAxisLocation = 'origin'; % box off % 坐标轴刻度 使用LaTex公式 xticks([0.5,1]); xticklabels({'$0.5$','$1$'}); yticks([0.5,1,1.5,2]); yticklabels({'$0.5$','$1$','$1.5$','$2.0$'}); ax.TickLabelInterpreter = 'latex'; x = [0.5 0.6]; y = [0.7,0.57];  annotation('textarrow',x,y,'String','$\alpha = 1,\beta = 1$ ','Interpreter','latex','FontSize',14) % 坐标轴箭头 annotation('arrow',[0.17, 0.17],[0.1, 0.99999],'LineWidth',1.5) annotation('arrow',[0.1, 0.999],[0.142, 0.142],'LineWidth',1.5);



https://blog.sciencenet.cn/blog-292361-1422483.html

上一篇:利用MATLAB生成超几何概率分布表
收藏 IP: 110.251.42.*| 热度|

1 黄河宁

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-27 16:21

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部