826 points · by bookofjoe · 7y ago · 207 comments
This is how I feel about engineering.
If you design something, prove it out with logic and math. It will work.
Or you will learn where you were wrong.
In other words, if you design something and prove it out with logic and math, sometimes it will work and sometimes it won't...
Also, specific to Engineering, there are countless tools that help making sure your product will have a high probability of working as intended, anything from CAD tools, simulation tools (which it could be argued are a more automated way of applying logic and math), QA processes, etc.
The last one there was more a comfort level thing...people like to not fall down to the next floor, but they also like to not feel AS IF they'd fall down to the next floor...to you overdesign to remove the vibration.
9 times out of 10, it was that NVH aspect that drove the design.
– Donald E. Knuth (1977)
Pursue your passions, whether it is climbing a huge mountain or finding identical packs of skittles. It is what makes the world great and interesting.
All your math can be correct but if your assumptions are incorrect, your results may not be accurate.
But to write his simulation, he just needs to fill virtual bags with random colors and count them, no math needed.
The only difference is, I normally spend my time automating the process with computer vision (a skittle sorter/counter wouldn't be that hard to build; opening the bag is harder than identifying colors). And then I never really finish the project.
One thing to remember in the panic over automation killing off jobs is that handling the normal case is maybe 20% of the work. Handling routine errors is 80% of the work. Handling the errors that crop up once in a thousand parts - or dozens of times in this small sample - is why running lights-out is so difficult, and why we'll always need human operators and maintenance staff who can diagnose and correct unexpected problems.
That said, I'm at least 97% confident that OP, in manually counting and marking down these 27,000 items, mis-counted or mis-marked at least once. So I'm not feeling too bad about my pessimism regarding the automated solution. Even if it can't identify if a given sample is "gross" or not, it will add 1 to a counter reliably!
Also, one test of 468 bags that shows one result does not prove anything about the average number required. You'd need to run this test many times for that, and for that you'd need automation!
The only requirement was a hopper for the teacher to dump the skittles into at the beginning. She would have a different amount for each group that was pre-counted and our numbers had to match hers at the end within a certain % of error.
It was a month+ long project and really fun to see each team's solution in how they moved/sorted/stored the final product. Some teams used long conveyor belts, others used short stacked belts, etc. It was all really interesting and I thoroughly enjoyed it!
Designing a hopper was a recently project for me and it was really fun. I learned a bunch about mass flow and realized that there are all sorts of interesting industrial problems involving hoppers.
I ended up learning there is a whole area of computer vision in industry- relatively "boring" stuff like just looking at a line of bottles going by. I went on a tour of the money making machines in DC and they stream sheets of bills by industrial vision cameras to detect whether the bills are within QC.
Still amazes me people get paid to do this. To me it's just like a big fun game.
I was thinking that time could be saved by not sorting the skittles so nicely. Just take a picture of the skittles from each bag spread out randomly. You should be able to figure out the color distribution just by counting pixels within each color range.
"That's why we built Loppy the Chopper over there."
And even this histogram assumes a distribution of total number of Skittles per pack (that varies) that I had to guess at beforehand. In hindsight, the final sample distribution suggests that I probably initially overestimated the true variance, and thus also overestimated the expected number of packs I would need to inspect. In other words, this experiment arguably took longer than "average."
So you're right-- this experiment could have extended into 700 packs, 800 packs... and still have been consistent with the assumed model, but I would have simply been in an unfortunate 90-th percentile possible universe where it took much longer than "average."
Honestly thought I was going to read a "just cause" blog on machine vision and process automation, e.g. 3 months to develop a functional prototype and train the system, 3 days to process 468 packs...and automated repeatability at the end of it all.
I can't imagine doing this manually - though it'd take me more time to write a Machine Vision solution rather than just doing it manually. :P
Btw, thats my next big overhaul. How would you want the data? Javascript HTML table?
edit: would love an explanation for the downvotes
* empty a pack of skittles onto white paper and take a photo
* use some existing image recognition libraries to count each color
* export to csv or smn and do excel magic
Hence, building.
It feels like an almost-trivial computer vision problem.
It took about an hour of Googling OpenCV questions. Also, I've never actually used OpenCV before, and don't use Python regularly.
I haven't tested it against the full set of images. Even if it's not perfect you could at least use this to narrow down ones that are within some threshold, then manually verify they were tagged correctly.
I'll post the code shortly.
Have you verified the author's claim that this is the only match in the whole data set?
My program isn't perfect, but I only spent a couple hours on it. I think it could be improved, and better lightning when taking the photos would help too.
However, I was curious how well it did so I compared it to the author's results. My program misclassifies approximately 80 out of 27,740 Skittles.
I searched for matches and it did indeed find the same match the author found:
(0, './skittles/images/334.jpg', './skittles/images/464.jpg')
(1, './skittles/images/103.jpg', './skittles/images/384.jpg')
(1, './skittles/images/111.jpg', './skittles/images/134.jpg')
(1, './skittles/images/118.jpg', './skittles/images/353.jpg')
(1, './skittles/images/139.jpg', './skittles/images/168.jpg')
(1, './skittles/images/152.jpg', './skittles/images/281.jpg')
(1, './skittles/images/158.jpg', './skittles/images/244.jpg')
(1, './skittles/images/198.jpg', './skittles/images/255.jpg')
(1, './skittles/images/198.jpg', './skittles/images/334.jpg')
(1, './skittles/images/198.jpg', './skittles/images/464.jpg')
(1, './skittles/images/201.jpg', './skittles/images/338.jpg')
...etc
(first row is identical, subsequent rows are one different)Since there are some errors, I did get lucky. However, if it's good enough, you could also manually verify ones that are close.
Anyway, personally I'd rather write code than manually count 27,740 Skittles, but I'm grateful the author did this because it's an interesting dataset to work with.
It's definitely not perfect but could probably be improved a bit.
There are a few where strawberry and grape or strawberry and lemon are swapped. I think better lighting would help.
https://hackaday.com/2017/02/06/mms-and-skittles-sorting-mac...
To the author's credit though, doing it manually probably made more sense in his situation. It would take a few months to build the auto-sorter, which would've had to be tweaked to handle the misshapen blobs. The collection of Skittles photos is impressive too, and hopefully will end up in a Maths classroom.
If you're pretty good with Tensorflow, you could do it with an object detector. I've built absurdly accurate object detectors using the TF Object Detector tutorial and just a little hand labelled data plus some good synthetic augmentation.
For this project's scope and scale it's probably not worth automating unless you're going to be repeatedly running the process.
Counting the number of round colored objects on a white background is not a hard problem.
I think I've found a project for this evening...
It's a good book!
https://www.amazon.co.uk/Newtonian-Penguin-Science-29-Aug-19...
The teacher had us all "guess" what twenty coin flips would look like. The longest any streak any student wrote on their paper was maybe 4-ish in a row or something.
He then had us all actually flip the coins and record the results. One student had like 11 in a row, most hit a streak of somewhere between 5-8 of the same result.
Lesson learned, we're really bad at guessing 50/50 streaks.
(1/5)^59 = 1/1.73*10^41
Apparently ~200 million skittles are made daily, so at that rate, we might expect to get a monochrome bag of skittles after ~10^33 years.
Apple is culturally significant and Blackcurrants are banned in the US (due to then carrying a disease that would devastate one of the forests). So one is more important than lime and the other is totally unfamiliar.
https://possiblywrong.wordpress.com/2019/04/06/follow-up-i-f...
[1]: https://www.amazon.com/Skittles-Original-Candy-2-17-Pack/dp/...
Since this is a nerd site, the next step is to use this:
Build a Lego contraption to push some skittles through a sensor that counts them.
They do speculate that the number of candies per pack is not IID, i.e., that there are (anti)correlations from one pack to the next. But without knowing more about the packing process, and presumably also having some lot/serial number information for each pack, it would be pretty hard to establish this.
This is similar tot the birthday problem: How many people do you need to have a probability of > x% that two are born on the same day?
It's something like 50 people to have a probability of > 80%. You can conduct this experiment at a school, using each class as a sample experiment to see if there are two pupils born on the same day.
> As an aside, I think the fact that this particular concrete application happens to be recreational, or even downright frivolous, is beside the point. For one thing, recreational mathematics is fun. But perhaps more importantly, there are useful, non-recreational, “real-world” applications of the same underlying mathematics. Cryptography is one such example application; this experiment is really just a birthday attack in slightly more complicated form.
I would say one of the first great discoveries for a person is the exponential series (a real world examples: population growth). Another is the divergence of the harmonic series 1/n and convergence of 1/n^2 (my preferred real world example: pizza slices that converge to 1 pizza or diverge to infinitely many). E.g. give me 1/n slices for the rest of my life and I'll pay you $100 (-:
When travelling, I also have go-to experiments that I like doing (e.g., elementary proofs that the earth is round/spherical such as: great circles; N-E-S-W always at 90 degrees; shadow angles [Erastothenes]; seasons; etc.)
There are other things to investigate that are not really "proofs" or "combinatorial evidence", but equally interesting. One example is using music (esp. the piano) as a physical logarithm device. The music "sounds" additive but the frequencies are multiplicative.
I've just ordered a huge box of fun sized M&M packets and will try using computer vision to count them to copy this study from start to finish for learning purposes.
"Yeah, I learned from this experiment that I don’t actually like Skittles, which is probably good, so a lot of Skittles were bagged and handed off to relatives. "
A few hours with a blob detection tutorial would have saved hours of tedium.
There is no formal definition of "a potato chip bag". Hence it's possible to "just" create "a single potato chip bag"...
No reason, no monetary plan.
Having said that, this small sample is indeed reasonably consistent (or at least not inconsistent) with that iid assumption for the color of each individual Skittle. We would not expect to see any 80+% red packs even assuming that color was perfectly uniformly iid, because the probability of observing such a pack is so small (less than 10^(-19)).
However, still assuming this model, we should expect to see packs with very small proportion of reds... and we do, with one pack having just 3 red Skittles, for example. The entire distribution of proportion of red follows the assumed binomial distribution very closely.