0

Let's say you have a machine that runs on an algorithm with inputs that can be modified. Every 3 months, that machine produces 40,000,000 widgets. You can monitor if the widgets are being made correctly immediately after each one is produced. How many days (hours?) should I let the machine run to see if the latest inputs are operating correctly?

If I use sampling calculators online, for a 99% confidence level and a confidence interval of 1%, I get a sample size of 16,634 - this represents roughly 1 hour of my machine's production. Evaluate 3 months of production on 1 hour's worth of performance? That doesn't seem right so I'm wondering if I'm misapplying sample sizing?

Unknown Coder
  • 166
  • 1
  • 1
  • 7

2 Answers2

1

You have the correct sample size, but I think you are misapplying the conditions under which testing is taking place. Units are selected at random, therefore performance should not be based on 1 standard hour (say 09:00-10:00 on a Monday morning), but random units from random times are tested.

I am going to assume that the testing is either destructive or costly, which is why you can't test all units continuously. The sampling schema takes the destructive/costly aspect into account to calculate a minimum sample size given the error rates you input.

  • Great answer. To be clear, my focus is more on making sure that I don't change my production algorithm too soon. In other words, I want to give the algorithm enough time (within the 3 months) to make good products or make mistakes. I don't want to abandon a potentially successful algorithm just because I evaluated results too early. I hope that makes sense. – Unknown Coder Feb 09 '17 at 18:26
1

Disclaimer: I am quite sceptic about statistical inference its tests and some of its concepts (sample size amongst them). I always recommend this article by Breiman to anyone working with data. My answer comes from a practitioner's perspective and I would never use it in a math exam (that's how I obtained my degree).

Regarding your particular problem, I believe the issue rather than a sample size problem is a experiment-design / sampling scheme one. You should consider some things before deciding your sampling.

  1. How costly is for you to gather data
  2. Does your process change over time
  3. Do you know beforehand any variable affecting the production

I work in the manufacturing sector and the most important constraint faced is often the first one. If you were able to collect your variable of interest you do not need statistics at all.

The second point is relevant in factories as machines and their components tend to deteriorate over time. This means sampling today is not the same as sampling next week (the samples do not come from the same population).

The third point is more blurry, but there are usually some production variables that are known in advance and should be kept in account when designing the sampling. For instance, I recall finding a 5% increase in the active power of a machine when a scrap melting oven was working at the same time.

All that said, if your process changes over time, I think the best thing to do is to sample periodically as randomly as you can. Once you set a sampling schedule, a simple bayesian Beta-Bernoulli model can be quite efficient handling incremental data and taking advantage of prior samples.

I post a simple implementation of the Beta-Bernoulli in R as an example. There is an excellent post on bayesian statistics using a Beta-Binomial here.

# Process performance at the beginning
init.process<-0.99
# deterioraion factor
deterioration.factor<-1.01

# alpha and beta priors 
alpha<-0.5
beta<-0.5

# forgetting rate, included so the new observations
# have more weight in the posterior distribution
lambda<-1.5
# for reproducibility
set.seed(13)
# use samples when they are collected at time t
for(t in 0:10){
  # real parameter
  p<-init.process/deterioration.factor^t
  q<-1-p
  #sample 100 widgets
  sampt<-sample(2,100,replace=TRUE,prob=c(q,p))-1L
  # get posterior alpha and beta
  alpha<-alpha+sum(sampt==1L)
  beta<-beta+sum(sampt==0L)
  # get the 5th percentile
  perc<-qbeta(0.05,alpha,beta)
  print(paste("The real parameter is",round(p,3)))
  print(paste("Your parameter is larger than",round(perc,3),
              "with 95% probability"))
  # reduce weight from old observations
  alpha<-alpha/lambda
  beta<-beta/lambda
}
Jon Nagra
  • 353
  • 3
  • 10
  • Great answer. To be clear, my focus is more on making sure that I don't change my production algorithm too soon. In other words, I want to give the algorithm enough time (within the 3 months) to make good products or make mistakes. I don't want to abandon a potentially successful algorithm just because I evaluated results too early. I hope that makes sense. – Unknown Coder Feb 09 '17 at 18:26
  • It does make sense, but, unfortunately there are many factors involved (especially the cost). As a piece of advice, I would favour frequency over size. In case the production does not vary much from day to day your information will be close to the reality from the beginning, and in case it does vary a lot you will want to have samples from different points in time. Sorry for not being able to provide you more help, but the matter is complex and varies a lot from case to case. – Jon Nagra Feb 09 '17 at 21:14