Lauren Talluto
02.02.2026




… and so on.
What is the MLE? Is there a logical problem with that?
\[ s \sim Uniform(min = 1, max = N)\]

\[ t(x) = pr(s|N) \sim Uniform(s,N) \]
Algorithm

Algorithm
This is incredibly inefficient
s = 200
target = function(x) dunif(s, 1, x)
proposal = function(x) dunif(x, 1, 1e6)
## this scale will make sure p(x) >= t(x)
scale = target(s) / proposal(s)
candidates = as.integer(runif(1e6, 1, 1e6))
r = target(candidates)/(proposal(candidates) * scale)
## Warning in dunif(s, 1, x): NaNs produced
## uniform numbers between 0 and 1
test = runif(length(r))
## TRUE if r > test; WHY?
accept = ifelse(r > test, TRUE, FALSE)
samples = candidates[accept]
\[ S_t = S_{t-1} + fecundity \times S_{t-1} - mortality \times S_{t-1} \]


\[ pr(\theta | X) \propto pr(X | \theta)pr(\theta) \]

\[ pr(\theta | X) \propto pr(X | \theta)pr(\theta) \]

\[ pr(\theta | X) \propto pr(X | \theta)pr(\theta) \]

\[ pr(\theta | X) \propto pr(X | \theta)pr(\theta) \]

\[ pr(\theta | X) \propto pr(X | \theta)pr(\theta) \]

Algorithm
Define t(x): log unnormalized posterior (i.e, "target") distribution
Define p(x): the proposal distribution
common: rnorm(n = 1, mean = x, sd = proposal_scale)
Choose state[0] (the starting value)
for i in 1:n_samples
candidate = p(state[i-1], proposal_scale)
r = exp( t(candidate) - t(state[i-1])) ## acceptance probability
if r > runif(1) ## coin flip to see if we accept or not
state[i] = candidate
else
state[i] = chain[i-1]
mcmc_hist() and
mcmc_pairs (multivariate)
sampling instead of
optimization.