Skip to content

Sample points on a disk with radius r that no two points is closer to each other than d

Notifications You must be signed in to change notification settings

v-iashin/GibbsSampler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gibbs Sampler in R

My image

Problem Statement

(Ross, p. 252) Suppose we want to generate n random points in the circle of radius r centered at the origin, conditional on the event that no two points are within a distance d of each other, where

is assumed to be a small positive number. (If were not small, then we could just continue to generate sets of n random points in the circle, stopping the first time that no two points in the set are within d of each other.)

Algorithm

  1. Start with n points in the circle, , such that no two are within a distance d of each other.
  2. Then generate a random number U and let .
  3. Generate a random point in the circle.
  4. If this point is not within d of any of the other n - 1 points excluding then replace by this generated point; otherwise, generate a new point and repeat the operation.
  5. After a large number of iterations, the set of n points will approximately have the desired distribution.

Repository Files

  • unif_circle.R the function that implements the first step of the algorithm (initialization);
  • gibbs_sampler.R the function that does the rest of the algorithm steps;
  • example.R contains the code that implements the algorithm given some arbitrary parameters;
  • gibbs_sampler_plot.png illustrates the results of the algorithm (see the construction in example.R).

About

Sample points on a disk with radius r that no two points is closer to each other than d

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages