1
$\begingroup$

I'm trying to determine the bias on a gyro that is under constant motion. The way I've been doing this is sampling it over a long period (~1 minute at 100Hz) and taking the average. However, if there is lots of motion, I need to sample longer, and if there is no motion just a few seconds is enough.

How would I be able to determine the number of samples required for a certain CI based on the amount of motion being experienced?

$\endgroup$

1 Answer 1

1
$\begingroup$

I assume you want to find $n$ such that the margin of error $M$ in a 95% confidence interval (CI) is of a desired size.

First, you need to have large enough time intervals between observations, so that your measurements $X_1, X_2, ..., X_n$ are independent. Also, to find a CI you need to be reasonably sure that the gyro is stable in a probability sense so that the $X_i$ can be considered all to have come from the same distribution.

If you knew that the population has $Var(X_i) = \sigma^2,$ then a 95% CI for the the population mean $E(X_i) = \mu$ would be of the form $$\bar X_n \pm 1.96 \sigma/\sqrt{n},$$ where $\bar X_n$ is the sample mean of a sample of size $n$ and $\pm 1.96$ cut 2.5% of the probability from the lower and upper tails, respectively, of a standard normal distribution. (We are assuming that $\bar X_n$ is nearly normal, which is reasonable if $n$ is moderately large and the distribution of the $X_i$s is not serverly skewed.) Thus the 'margin of error' for your CI is $1.96 \sigma/\sqrt{n}$ and the total length of the CI is twice that.

But I suppose you do not know the value of $\sigma$ and propose to estimate it by the sample standard deviation $S_n$ of your sample of size $n.$ Then a 95% CI for $\mu$ is of the form $$\bar X_n \pm t^*S_n/\sqrt{n},$$ where $\pm t^*$ cut 2.5%of the probability from the lower and upper tails, respectively, of Student's t distribution with degrees of freedom $\nu = n-1.$

You could find the margin of error and the total length of this CI in the obvious way. But there is a slight difficulty that the value $t^*$ changes depending on $n.$ However, if $n > 30,$ then $t^* \approx 2,$ regardless of the sample size $n$.

So, roughly speaking, you can take the margin of error to be $M = 2S/\sqrt{n},$ where $S$ is the sample SD from previous experiments with similar amounts of 'motion'. Choose the margin of error $M$ that you seek and solve for $n = (t^*S/M)^2 = (2S/M)^2.$

If the $n$ you get is much smaller than $n = 30,$ then look at a printed table of Student's t distribution and use the appropriate $t^*.$ That will give a 'new' $n.$ Use the corresponding 'new' $t^*$ for the 'next' $n.$ Iterate a couple of times and $n$ will stabilize.

There are more elegant ways to solve this using a programmed 'quantile function' of the t distribution. However, as you see, a certain degree of guesswork is involved in estimating $\sigma$ by $S,$ so the method I propose should get you to a workable value of $n.$

Note: A 'sequential' approach would be to find the CI after each few observations are taken (easy enough to program on a calculator) and stop when the CIs settle to the desired length.

$\endgroup$
3
  • $\begingroup$ The issue here is that I don't know the level of motion that the gyro will experience as it is on a moving platform (in this case a raft) and is also affected by wind gusts, so I don't have any good way of experimentally determining the standard deviation, which your response seems to depend on, unless I'm misunderstanding. $\endgroup$
    – Otus
    Commented Feb 1, 2017 at 18:29
  • $\begingroup$ You can estimate the variance $\sigma^2$ by $S_n^2 = \frac{1}{n-1}\sum_{i=1}^n (X_i - \bar X)^2.$ The square root of that is the sample SD $S_n$ in my second displayed expression. Without some way of estimating SD you are not going to be able to get a CI. Presumably you can estimate the process mean $\mu$ by $\bar X;$ why not estimate the process SD $\sigma$ by $S.$ $\endgroup$
    – BruceET
    Commented Feb 1, 2017 at 21:40
  • $\begingroup$ Great answer! I would like to recommend a book that talks about the fundamentals behind BruceET. The book is: Sensor and Data Fusion: A tool for information assessment and decision making by Lawrence A. Klein. Chapter 4. Classical Inference $\endgroup$ Commented Nov 13, 2023 at 23:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.