Last active
January 9, 2019 21:34
-
-
Save dwinter/56524119a014f886755470be3fd4729c to your computer and use it in GitHub Desktop.
uniform sampling on a (half) disk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sample_half_disk <- function(n,radius) { | |
prop_radius <- runif(n) | |
angles <- runif(n,0,360) | |
data.frame( x= sqrt(prop_radius) * cos(angles) * radius, | |
y = -abs(sqrt(prop_radius) * sin(angles) * radius)) | |
} | |
plot(sample_half_disk(1e4,300)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment