Maximum likelihood

X <- rbinom(50, 1, .3)
head(X)
## [1] 1 0 0 0 0 1
p_hat <- mean(X)
p_hat
## [1] 0.36

p <- seq(.01, .99, .01)
head(p)
## [1] 0.01 0.02 0.03 0.04 0.05 0.06
log_likelihood <- sum(X) * log(p) + 
  (length(X) - sum(X)) * log(1-p)
head(log_likelihood)
## [1] -83.21467 -71.06290 -64.09274 -59.24607 -55.56457 -52.62141

qplot(p, log_likelihood, geom = 'line') +
  geom_vline(xintercept = p_hat, linetype = 'dashed')