This is first off, a pure learning experience, and a thought experiment that I haven't thought too long on. So go easy on me. I just thought it would be a good one to toss out here and see what comes back.
I need Arduino to predict the future. I couldn't find a Future library, so I'm going to have to do this myself.
The problem I have to solve is keeping the levels of two chemicals stable within limits in some water based on scheduled testing results. The problem is a simple one if you know the rate of consumption. You just match it. But in this case, there are a number of semi-random events (water removed, water added with unknown level etc. etc.) that are going to impact that consumption rate either positively or negatively. The overall natural rate can increase and decrease by small amounts randomly.
But the project has plenty of power, almost 2 gigs of leftover room on an SD card, and 2 hours to kill between actual doses. Why not give it something to do?
So what about a Monte Carlo approach? The events are random, but usually small in number, so the math to run each one of the infinite number of simulations is pretty simple. I know the basic statistical distribution of the events. In the two hours I have, I could run thousands of simulations with randomly placed but statistically level events happening, keep the results on the SD, and then average the results into a new dosing scheme. Perhaps even weight the average based on performance and keeping steady simulated levels.
The pieces seem doable. Running a simlation based on a known addition rate over a set amount of time with the last known consumption rate and some randomly timed and randomly sized change events. A little hard-coded math to get the stats right. Some hard coded math that either uses calculus or just runs through the simulation since it's simple and returns the levels at the end. If the level is too high or too low at the end, then you apply a random algorithm to take a step with the number and run the simulation again. In the data of dosing rates and final outcomes, there is an average that would be the best guess. That math doesn't seem too hard with so few variables. Average them and weight by how far off they were would be my first guess. I know enough about that math to tweak it by hand until I can think of a way for the computer to handle it.
The question isn't one that has to be solved. I'll be watching the numbers with a human eye the whole time. If I am up to the math, do you think Arduino could be up to such a computational challenge? Am I totally over-thinking this situation?