This is a program to generate samples from standard normal distribution using Metropolis algorithm. The proposal distribution used here is uniform distribution between x-1 and x+1.

Here we sample only one number from each chain, which is the number at the final step. Therefore you should enter the number of samples you want in "The number of chains".

Input:
The number of chains:
Number of steps in each chain:
Initial value for each chain:



Output:
Completedchains.
The numbers at the end of each chain are:

View page source

Acknowledgement: The histogram function was written by Ke Yang.


Haihong Li
haihong@stat.psu.edu