Maximum likelihood estimate of Gaussian given rounded observations Suppose there is a hidden gaussian with mean $\mu$ and variance $\sigma^2$, and that $X_i \sim \mathcal{N}(\mu,\sigma^2)$ where the $X_i$ are i.i.d.  If I can only oberve the rounded value of $X_i$, i.e. $Y_i = \lfloor X_i + 1/2 \rfloor$, is there an effective means of computing the maximum likelihood estimates of $\mu$ and $\sigma$?  
 A: As @Björn suggests, using package software is likely to work best in that the code is (again, more likely to be) debugged, have better documentation, be repeatable, less prone to numerical precision issues, and gives you someone else to blame.
But if you need to write your here is a bare-bones approach using R:
# Generate data
  set.seed(12345)
  x = rnorm(100, mean=20, sd=2)

# Round data
  y = round(x)

# Define log likelihood function
  logL = function(p, z) {
    mu = p[1]
    sigma = p[2]
    sum(log(pnorm(z+0.5, mu, sigma)-pnorm(z-0.5, mu, sigma)))
  }

# Initial values
  mu0 = mean(y)
  sigma0 = sd(y)

# Find maximum likelihood estimates
  sol = optim(c(mu0, sigma0), logL, z=y, control=list(fnscale=-1), hessian=TRUE)

# Show results
  cat("MLE of mu: ", sol$par[1], "\n")
# MLE of mu:  20.46009

  cat("MLE of sigma:", sol$par[2], "\n")
# MLE of sigma: 2.277309 

# Estimates of standard errors and covariance
  cov = solve(-sol$hessian)
  cat("se of MLE of mu:", cov[1,1]^0.5, "\n")
# se of MLE of mu: 0.2295532 
  cat("se of MLE of sigma:", cov[2,2]^0.5, "\n")
# se of MLE of sigma: 0.1636504 

A: (My solution is basically the same as what @JimB suggested in his comment.)
First, some theory:
We can think of $[x]=x+\epsilon$ where $f(\epsilon) \sim (1-\delta)+2\delta\epsilon$ for $1/2\le \epsilon \le 1/2$. This is a sloping distribution that approximates $N(x|\mu,\sigma^2)$) by a line with slope $2\delta=N'([x]|\mu,\sigma^2)=-\frac{[x]-\mu}{\sigma^2} N([x]|\mu,\sigma^2)$. We see that $\delta$ is nearly zero when $x \sim \mu$ or when $x\gg\mu$ or $x\ll\mu$. $\delta$ is a maximum value around the inflection points $[x] \sim \pm \sigma$, which is where a lot of the action happens.
The mean of $y$ is found to be an unbiased estimator of $\mu$.
$$E(y)=E([x])=E(x+\epsilon)=E(x)+E(\epsilon)=E(x)=\mu$$
where I have used $E(\epsilon)=0$ since $E(\delta)=0$ by symmetry.
For variance,
$$var(y)=var([x])=var(x+\epsilon)=var(x)+var(\epsilon)$$
where $var(\epsilon)$ is estimated as a function of $\delta$ to be 
$$var(\epsilon) \sim 1/12 - \delta^2/36=\frac{1}{12} (1-\delta^2/3).$$
This would now have to be averaged over the distribution of values of $\delta,$ which is doable but tedious. 
On 10,000 simulations of 1000 random normals with means around 50 and variances around 100, I find 

which contains at least one big surprise. The average value is $1/12$ as perhaps expected, but this figure shows that for about half of the simulations, the effect of rounding the data to integer is to underestimate $\sigma^2$ rather than to overestimate it, as would be expected from basic probability theory. 
Perhaps this is because there is assumption that $x$ and $\epsilon$ are independent is false!
Regardless, now to the optimization problem in $\mu$ and $\sigma$
Here is an example, in R.
rm(list=ls())

mu=50
sigma=10
N=1000
data=rnorm(N,mu,sigma)
idata=round(data,0)

indices<-seq(round(mean(idata)-5*sd(idata)),round(mean(idata)+5*sd(idata)))

logLike<-function(pars,idata,indices){
  mu=pars[1]
  sigma=pars[2]
  imin=min(indices)
  ps<-pnorm(indices+.5,mu,sigma)-pnorm(indices-.5,mu,sigma)
  logps<-log(ps)
  -sum(logps[idata-imin+1])
}
startingPars=c(mean(idata),sd(idata))
oo<-optim(startingPars,logLike,idata=idata,indices=indices,control=list(reltol=1e-12))
print(paste("target Sigma",sigma))
print(paste("sample sigma",sd(data)))
print(paste("sample integerized sigma",sd(idata)))
print(paste("optimized sigma",oo$par[2]))

One example of this gives
[1] "target variance 127.743486150357"
[1] "sample variance 124.050532385344"
[1] "sample rounded variance 124.173364364364"
[1] "optimized variance 123.965644616766"

In this one case, we see that rounding increases the variance and that optimizing reduces the estimate to a value closer to the original sample variance, which is the best linear unbiased estimator of the target variance.
