T=;
sigma=;
thetamin=-;thetamax=;
theta=zeros(,T);
seed=;rand('state',seed);randn('state',seed);
theta()=unifrnd(thetamin,thetamax);
t=; while t<T
t=t+;
theta_star=normrnd(theta(t-),sigma);
alpha=min([ cauchy(theta_star)/cauchy(theta(t-))]);
u=rand;
if u<alpha
theta(t)=theta_star;
else
theta(t)=theta(t-);
end
end figure();clf;
subplot(,,);
nbins=;
thetabins=linspace(thetamin,thetamax,nbins);
counts=hist(theta,thetabins);
bar(thetabins,counts/sum(counts),'k');
xlim([thetamin thetamax]);
xlabel('\theta');ylabel('p(\theta)');
y=cauchy(thetabins);
hold on;
plot(thetabins,y/sum(y),'r--','LineWidth',);
set(gca,'YTick',[]);
subplot(,,:);
stairs(theta,:T,'k-');
ylabel('t');xlabel('\theta');
set(gca,'YDir','reverse');
xlim([thetamin thetamax]);

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGsAAAJUCAIAAAAttzyIAAAgAElEQVR4nO3dW3ajuAJAUeY/tszJ/eGUWxEPC5DQa+91P24cQkBRA6cgzvIDAABAmqX2BgAAAHRDQQEAAKRSUAAAAKkUFAAAQCoFBQAAkEpBAQAApFJQAAAAqRQUAABAKgUFAACQSkEBAACkUlAAAACpFBQAAEAqBQUAAJBKQQEAAKRSUAAAAKkUFAAAQCoFBQAAkEpBAQAApFJQAAAAqRQUAABAKgUFAACQSkEBAACkUlAAAACpFBQAAEAqBQUAAJBKQQEAAKRSUAAAAKlaKagFAAAgt/zlkn2N1yzL8oJ/zAdC5gMRU4KQ+UDIfCCioJiF+UDIfCBiShAyHwiZD0QUFLMwHwiZD/xalj//g9fr5RDBX+YDEQXFLMwHQuYDr9cqn3QU/zhEEDIfiCgoZmE+EDIf2M2nZXlt/dJw7c3lUX7ihMwHIgqKWZgPhMwHFBQH/MQJmQ9EFBSzMB8ImQ9Ej+0tqw8V1Mz8xAmZD0QUFLMwHwiZD2wU1J9PKqip+YkTMh+IKChmYT4QMh9mt3rrCAVFyE+ckPlA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DW1bWr9fdQqpYH+/MB37MBP5xiODHJQRbnqkMEwsAACCVggIAAEiloAAAAFIpKAAAgFQKCgAAIJWCAgAASKWgAAAAUikoAACAVAoKgG74E5kAVOc8BEAfPu0kogCoyEkIgA5E1SSiAKjFGQiADigoABrxH92xOeB1BFO6AAAAAElFTkSuQmCC" alt="" />

function y=bivexp(theta1,theta2)
lambda1=0.5;
lambda2=0.1;
lambda=0.01;
maxval=;
y=exp(-(lambda1+lambda)*theta1-(lambda2+lambda)*theta2-lambda*maxval);
T=;
thetamin=[ ];
thetamax=[ ];
seed=;
rand('state',seed);
randn('state',seed);
theta=zeros(,T);
theta(,)=unifrnd(thetamin(),thetamax());
theta(,)=unifrnd(thetamin(),thetamax()); t=;
while t<T
t=t+;
theta_star=unifrnd(thetamin,thetamax);
pratio=bivexp(theta_star(),theta_star())/bivexp(theta(,t-),theta(,t-));
alpha=min([ pratio]);
u=rand;
if u<alpha
theta(:,t)=theta_star;
else
theta(:,t)=theta(:,t-);
end
end figure();clf;
subplot(,,);
nbins=;
thetabins1=linspace(thetamin(),thetamax(),nbins);
thetabins2=linspace(thetamin(),thetamax(),nbins);
hist3(theta','Edges',{thetabins1 thetabins2});
thetabins1=linspace(thetamin(),thetamax(),nbins); xlabel('\theta_1');ylabel('\theta_2');zlabel('counts');
az=;el=;
view(az,el);
subplot(,,);
nbins=;
thetabins1=linspace(thetamin(),thetamax(),nbins);
thetabins2=linspace(thetamin(),thetamax(),nbins);
[theta1grid,theta2grid]=meshgrid(thetabins1,thetabins2);
ygrid=bivexp(theta1grid,theta2grid);
mesh(theta1grid,theta2grid,ygrid);
xlabel('\theta_1');ylabel('\theta_2');
zlabel('f(\theta_1,\theta_2)');
view(az,el);
function tau=kendalltau(order1,order2)
[dummy,ranking1]=sort(order1(:)',2,'ascend');
[dummy,ranking2]=sort(order2(:)',2,'ascend');
N=length(ranking1);
[ii,jj]=meshgrid(:N,:N);
ok=find(jj(:)>ii(:));
ii=ii(ok);
jj=jj(ok);
nok=length(ok);
sign1=ranking1(jj)>ranking1(ii);
sign2=ranking2(jj)>ranking2(ii);
tau=sum(sign1~=sign2);
lambda = 0.1; % scaling parameter
labels = { 'Washington' , 'Adams' , 'Jefferson' , 'Madison' , 'Monroe' };
omega = [ ]; % correct ordering
L = length( omega ); % number of items in ordering
T = ; % Set the maximum number of iterations
seed=; rand( 'state' , seed ); randn('state',seed ); % set the random seed
theta = zeros( L , T ); % Init storage space for our samples
theta(:,) = randperm( L ); % Random ordering to start with
t = ;
while t < T % Iterate until we have T samples
t = t + ;
lasttheta = theta(:,t-); % Get the last theta
whswap = randperm( L ); whswap = whswap(:);
theta_star= lasttheta;
theta_star( whswap()) = lasttheta( whswap());
theta_star( whswap()) = lasttheta( whswap());
dist1 = kendalltau( theta_star , omega );
dist2 = kendalltau( lasttheta , omega );
pratio = exp(-dist1*lambda) / exp(-dist2*lambda);
alpha = min( [ pratio ] );
u = rand; % Draw a uniform deviate from [ ]
if u < alpha % Do we accept this proposal?
theta(:,t) = theta_star; % proposal becomes new theta
else
theta(:,t) = lasttheta; % copy old theta
end
if mod( t, ) ==
fprintf( 't=%3d\t' , t );
for j=:L
fprintf( '%15s' , labels{ theta(j,t)} );
end
fprintf( '\n' );
end
end

《Computational Statistics with Matlab》硬译2的更多相关文章

  1. 《Computational Statistics with Matlab》硬译

    第1章 从随机变量采样 研究者提出的概率模型对于分析方法来说通常比较复杂,研究者处理复杂概率模型时越来越依赖计算.数值方法,通过使用计算方法,研究者就不用对一些分析技术做一些不现实的假设(如正态性和独 ...

  2. numpy-Randow

    Randow使用 http://blog.csdn.net/pipisorry/article/details/39508417 概率相关使用 转:http://www.cnblogs.com/Nau ...

  3. 标准差分进化算法matlab程序实现(转载)

    标准差分进化算法matlab程序实现 自适应差分演化算法方面的Matlab和C++代码及论文 差分进化算法 DE-Differential Evolution matlab练习程序(差异演化DE) [ ...

  4. matlab中文显示乱码:控制台上的,编辑器的,图片中的

    问题:matlab脚本与函数文件的中文注释显示乱码. 环境:matlab R2016a.Windows 10 home. 解决方案: step1 检查locale值 matlab命令行键入命令 fea ...

  5. 数学类网站、代码(Matlab & Python & R)

    0. math & code COME ON CODE ON | A blog about programming and more programming. 1. 中文 统计学Computa ...

  6. 【原创】开源Math.NET基础数学类库使用(13)C#实现其他随机数生成器

                   本博客所有文章分类的总目录:[总目录]本博客博文总目录-实时更新  开源Math.NET基础数学类库使用总目录:[目录]开源Math.NET基础数学类库使用总目录 前言 ...

  7. 统计计算与R语言的资料汇总(截止2016年12月)

    本文在Creative Commons许可证下发布. 在fedora Linux上断断续续使用R语言过了9年后,发现R语言在国内用的人逐渐多了起来.由于工作原因,直到今年暑假一个赴京工作的机会与一位统 ...

  8. 开源Math.NET基础数学类库使用(13)C#实现其他随机数生成器

    原文:[原创]开源Math.NET基础数学类库使用(13)C#实现其他随机数生成器                本博客所有文章分类的总目录:http://www.cnblogs.com/asxiny ...

  9. CV code references

    转:http://www.sigvc.org/bbs/thread-72-1-1.html 一.特征提取Feature Extraction:   SIFT [1] [Demo program][SI ...

随机推荐

  1. [LintCode] 最后一个单词的长度

    class Solution { public: /** * @param s A string * @return the length of last word */ int lengthOfLa ...

  2. Go语言性能优化

    原文:http://bravenewgeek.com/so-you-wanna-go-fast/ 我曾经和很多聪明的人一起工作.我们很多人都对性能问题很痴迷,我们之前所做的是尝试逼近能够预期的(性能) ...

  3. <2014 05 16> 线性表、栈与队列——一个环形队列的C语言实现

    栈与队列都是具有特殊存取方式的线性表,栈属于先进后出(FILO),而队列则是先进先出(FIFO).栈能够将递归问题转化为非递归问题,这是它的一个重要特性.除了FILO.FIFO这样的最普遍存取方式外, ...

  4. AwesomePerfCpp 性能优化

    Contents Talks Articles Sites/Blogs Tools Libraries Books About Talks 2013: Going Native 2013 - Andr ...

  5. Python获取指定目录下所有子目录、所有文件名

    需求 给出制定目录,通过Python获取指定目录下的所有子目录,所有(子目录下)文件名: 实现 import os def file_name(file_dir): for root, dirs, f ...

  6. django博客项目5:博客首页视图(2)

    真正的 Django 博客首页视图 在此之前我们已经编写了 Blog 的首页视图,并且配置了 URL 和模板,让 Django 能够正确地处理 HTTP 请求并返回合适的 HTTP 响应.不过我们仅仅 ...

  7. Django限制请求method

    1.常用的请求method 1.1 GET请求: GET请求一般用来向服务器索取数据,但不会向服务器提交数据,不会对服务器的状态进行更改.比如向服务器获取某篇文章的详情. 1.2 POST请求: PO ...

  8. Spring-Spring概述

    Spring概述 Spring是最受欢迎的企业级Java应用程序开发框架.数以百万的来自世界各地的开发人员使用Spring框架来创建好性能.易于测试.可重用的代码. Spring框架是一个开源的Jav ...

  9. (转)Nginx反向代理设置 从80端口转向其他端口

    from :http://www.cnblogs.com/wuyou/p/3455381.html Nginx反向代理设置 从80端口转向其他端口   反向代理(Reverse Proxy)方式是指以 ...

  10. linux sed批量替换多个文件内容

    sed -i "s/lgside/main/g" `grep -rl lgside /home/zn/work/project-template` 注意标点符号:`