联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> Algorithm 算法作业Algorithm 算法作业

日期:2020-07-24 11:33

Project 1.  

The computational efficiency is extremely important in modern computer-based calculations. Vectorized calculations, for example, avoid going through individual vector or matrix elements and avoid for() loops.

a.Please give a few examples to demonstrate the usage of the vectorized calculations.  

b.In addition, compare the execution times of three following equivalent R commands using Sys.time():

?y=c();for (t in 1:100) y[t]=exp(t)

?y=exp(1:100)

?y=sapply(1:100,exp)


Project 2.  

There are many distributions for which the inverse transform method will fail to be able to generate the required random variables. For these cases, we must turn to indirect methods such as so-called Accept-Reject methods, in which we generate a candidate random variable and only accept it subject to passing a test. These only require us to know the functional form of the density f of interest (called the target density) up to a multiplicative constant M and a simpler (to simulate) density g, called the instrumental or candidate density, to generate the random variable for which the simulation is actually done.

a.Write out the basic simulation procedure that allows us to simulate from the interested distribution f using the candidate density g.

b.Give an illustration of this indirect method, discuss its efficiency when different proposal distributions are used. Write out your R commands.


Project 3.


a.Explain the basic procedures or algorithms of some popular empirical methods as follows:

?Bootstrap methods to estimate the confidence intervals;

?Expectation-Maximisation (EM) algorithm to estimate iteratively parameters with missing or incomplete data or in situations where we can’t solve Maximum Likelihood Estimation (MLE) analytically;

?Metropolis and Metroplis-Hastings MCMC algorithm to generate dependent samples from the target distribution for solving the complicated integration problems;

?Gibbs sampler to sample from a multivariate distribution by sampling from the marginal distributions of the target distribution.

   

b.Write your own R commands to solve the following problems:

?Use the Metropolis-Hastings sampler to generate a sample from beta (2,2) distribution using a uniform(0,1) candidate distribution. Make a comparison between the quantiles of the targeted beta(2,2) distribution with the quantiles of the generated chain in a quantile-quantile plot.

?compare the above method with the following two alternative methods : ①. Accept-reject algorithm to simulate the beta(2,2)distribution; ②. the transformation method to simulate the beta (2,2) using gamma distributions.


c.Check the similarity of the above three different beta generators using:

?Histograms.

?overlaid density curves.

?Kolmogorov-Smirnov test.


版权所有:留学生编程辅导网 2018 All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。