Back Pedaling Honestly, I'm not even sure if this is the right question but I haven't been able to come up with anything that makes more sense so I'd appreciate some help. This is a real problem, not an exercise. Actually, I hope I'm missing something obvious and will feel dumb once someone puts me on the right track.
What's the question? What I'm asking is: Am I right? Is this the correct way to view the problem and does my approach make sense? If you think it is (and does), let me know. Even better if you can tell me why. Put another way, I am asking for a review. If you want to suggest a better title, please do.
This is a real problem so there are several extensions. If my initial approach is right, it leads to more questions. (doesn't everything?)
BruceET gives a nice solution but see my comment: Doesn't that result in two p-values to consider?
So here goes:
You are about to do a job (like some car repair) for which you have good reason to believe you will not need more that $n$ things, all the same. You have done this job before, and you do many kinds of jobs, some of which require the same things. If you don't have $n$ already, you will buy more. But more often than not, you don't use all $n$ things. You have records of the number of things you used each time you did the job.
More concretely: You are repairing a machine and you know how many parts it has. You know something is broken, and you have to shut down the machine to repair it. Until you start, you don't know how many parts you will need to replace, but you know the maximum. ($e.g.$ while replacing a manifold gasket, you may break some bolts...or not).
Once you start, you want to be very certain that you have everything you need, (or you may be walking to the auto parts store) but you would like to avoid buying more than you need. So you want to adjust $n$ based on experience so that $n=k$ where $k$ is the number of things you end up using.
This seems like repetitions of a binomial experiment to me (but I could be completely off), where $n$ is the number of attempts (to use the thing) and $k$ is the number of things you ended up using (success). All I can find is how to solve for $p$ given $n$ and $k$. It also seems like a very Bayesian sort of problem, but I think that would need many repetitions of the job to converge on a satisfactory solution.
My proposed solution
I'm thinking of finding the binomial confidence interval, given $n$ and $k$ and if that interval is not too close to 0 or 1 (either side), reducing $n$ until it is. Too close means either there isn't enough data for a "good" test or $n$ is fine as it is. Either way: don't change $n$. No, I'm not precisely sure what "too close" means.
But this seems kind of sketchy. So I'm asking for comments/suggestions.
By the way, if I'm thinking about it right, for any particular kind of job, it doesn't matter how many times the job was done, only the total of n and k across all the jobs (like flipping a coin multiple times, taking a break and then flipping the same coin more times).
The problem almost seems like a Poisson process but it isn't occurring over time or space (or any interval), each job is an event. Note that this seems related to failure rates but isn't quite. We already know something has failed, we just don't know how many things we'll want to replace.
Extension 1: You do many different jobs, each of which require multiple things.
Extension 2: Many of the "things" are indeed discrete (like bolts) but some are not (like gallons or feet). For those, I'm wondering if it really matters. Aren't 100 bottles of beer 100 discrete things?
Extension 3: Ultimately this is an optimization problem because if you don't have what you need, you lose money until you can finish the job.
Note: I hope I'm not violating some SE rule here with the extensions, if I get a good answer to the main problem, obviously I'll accept it and then maybe ask the extensions as separate questions. I just thought it would be good to give the whole picture.