How to determine "LCM" like value of a data series? I am analyzing data for Millikan - Fletcher's Oil drop experiment. In short, I have various values of charge Q, and would like to determine the "LCM" like value of this data series - which would correspond to the smallest quantization of charge.
I would like to know how this can be done algorithmically, preferably in Python. The data is somewhat noisy. For reference, you can check this question on Physics Stackexchange (see the first answer). Something like that method will help. I have still not understood how that algorithms works exactly.
 A: How you determine an appropriate "LCM" will depend on how you model the data. In the example you link, the model is something like
$$
q_i = \left(k_i + \epsilon_i\right)b
$$
where $q_i$ is a measurement, $k_i$ is a positive integer, the $\epsilon_i$ are iid measurement errors, and $b$ is a fixed (positive) base unit that does not vary between samples $i$.
The approach taken in your linked example is to estimate $b$ (and the $k$ values) by minimizing an estimate of the error magnitude. To see how this works, consider the following.
Given a value for $b$, the model equation can be rearranged to
$$
\frac{q_i}{b} = k_i + \epsilon_i
$$
where $k_i$ is a positive integer, and $\epsilon_i$ is expected to be "small". So a reasonable estimate for $k_i$ would be
$$
\hat{k}_i = \max\left[\mathrm{round}\left[\frac{q_i}{b}\right], 1\right]
$$
which gives an error estimate
$$
\hat{\epsilon}_i = \frac{q_i}{b} - \hat{k}_i
$$
The total error* could then be estimated as
$$
E(b) = \sum_i \vert\hat{\epsilon}_i\vert
$$
and then the final "LCM" estimate is gotten by minimizing the estimated total error
$$
\hat{b} = \arg\min_{b>0}E(b)
$$
where only positive values of $b$ are considered.
In python, this could be done with scipy (using e.g. $b\leq2q_\min$ as an upper bound).
(*Note: For Laplace errors, this would be the negative log-likelihood, and $\hat{b}$ would be the mle.)
