This commit is contained in:
2022-01-22 16:28:25 +08:00
parent 29f76af7fa
commit 03955990aa
9 changed files with 418 additions and 407 deletions

View File

@@ -0,0 +1,18 @@
% This code is supported by the website: https://www.guanjihuan.com
% The newest version of this code is on the web page: https://www.guanjihuan.com/archives/1247
clc;clear all;clf;
s=100000; %
f=[1,2,3,3,3,3,6,5,4,3,2,1]; %
d=zeros(1,s); %
x=1;
for i=1:s
y=unidrnd(12); % 112
alpha=min(1,f(y)/f(x)); %
u=rand;
if u<alpha % alpha
x=y;
end
d(i)=x;
end
hist(d,1:1:12);