Skip to content

Instantly share code, notes, and snippets.

@TonyLadson
Last active November 15, 2015 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TonyLadson/fa4480e70d5d39335057 to your computer and use it in GitHub Desktop.
Save TonyLadson/fa4480e70d5d39335057 to your computer and use it in GitHub Desktop.
Examples: Poission distribution as applied to the 100-year flood. https://tonyladson.wordpress.com/2015/06/29/100-year-flood-poisson-distribution/
dpois(0,1) # prob of zero 100-year floods in 100 years
dpois(0,1) # prob of zero 100-year floods in 100 years
[1] 0.3678794
dpois(1,1) # prob of one 100-year floods in 100 years
[1] 0.3678794
dpois(2,1) # prob of two 100-year floods in 100 years
[1] 0.1839397
# simulation
library(ggplot2)
df <- expand.grid(x = 1:10, y = 1:10)
df$z <- rbinom(100, 100, 0.01) # could also use rpois(100,1)
ggplot(data=df, aes(x,y)) + geom_tile(aes(fill=z)) +
scale_fill_gradient(low="green", high = "red", name = 'Floods') +
geom_text(data = df, aes(x, y, label = z)) +
scale_x_continuous(breaks = NULL) +
scale_y_continuous(breaks = NULL) +
xlab('') +
ylab('')
set.seed(2000)
rpois(10, 1)
[1] 0 1 0 1 2 1 3 1 2 1
# number of 100-year floods in each of 10 100-year sequences
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment