Skip to content

Instantly share code, notes, and snippets.

# create some random data
set.seed(123)
x <- rpois(100, lambda = 100)
# approach 1: hard to compare due to different aspect ratios
hist(x, breaks = c((min(x) - 1):(1 + max(x))))
plot(table(x), main = "Barplot of x")
# approach 2: easier to compare
library(dplyr)
#include <stdlib.h>
#include <stdio.h>
// samples the height of one structure for a given maximum height (H)
int sample_height(int maxHeight) {
int height = 0;
while (rand() % 2 == 1 & height < maxHeight) {
height++;
}
return height;