I'm not very well versed in statistics, but I have a data analysis project that tests a certain type of data fitting algorithm with simulated data. I want to validate my initialization logic of the algorithm against theory, but I can't wrap my head around it. I'm drawing sets of samples from a normal distribution $f(x,\mu,\sigma)$ with, let's say, $n$ samples each, which are then binned to a histogram as my simulated data.
My problem boils down to this: I need to evaluate how the number of samples in a certain histogram bin fluctuates across the sample sets. I can calculate the mean number of samples in the histogram bin $[x_1,x_2]$ with $n\cdot(\Phi(x_2)-\Phi(x_1))$. But how do I get the distribution of the number of samples in the bin around this mean value?
My intuition says that the number of samples in a certain histogram bin in the sample sets are still normally distributed around the mean value calculated above. Still, I don't know how to calculate the standard deviation of the distribution.
Edit: I may have explained things poorly, so I try to elaborate in more detail with an example.
If I draw $n = 1000$ random samples form a normal distribution $f(x,\mu = 500,\sigma = 5)$ and bin the samples to a histogram with integer bins, I get a following histogram with 77 samples in the bin containing the $\mu$. The mean number of samples in the bin [499.5,500.5] calculated using CDFs is $1000\cdot(\Phi(500.5)-\Phi(499.5))\approx 79.7$.
And sure enough, if draw $m=10^5$ sets of $n=1000$ random samples, bin them to histograms, and note the number of samples in the "center bin", I get the following normalized distribution: And if I fit a gaussian function to the distribution, I get $\mu_{fit} = 79.1$ and $\sigma_{fit} = 8.52$ that kinda confirms the mean value calculated with the CDF. But how do I get, or is it possible to get, the $\sigma$ theoretically?
The idea is that if I can deduce the "center bin", I could use the number of samples in that bin ($c$) to limit my search space for $n$: Let us say, for all intents and purposes, the value of $c$ is at most $6\sigma_{fit}$ away from the mean $c$, and the probable range for $n$ can be calculated from that, which can be used as a search space for the fitting algorithm.
And yes, I know there are several valid ways to fit Gaussian functions to data. The key idea is to test out a different way of fitting.