# Math machine learning

October 30, 2012

Whenever I observe my daughter, I find that she likes to collect things. The more, the better. Usually as much as she can carry. As she can not count, how can she distinguish, what are more things and what are less things?

*My daughter with objects in both hands*

The human being has two hands, and every hand has 5 fingers. The binary and decimal system -- as if to the manner born. Two hands to grasp things. Fingers are at that stage already useful but there is no obvious advantage to have 2 or 6 fingers, it is just more preferable to have a toy on every hand than on one. So at the beginning we have following situation: no toy on both hands - worst case, a toy on one hand - good, a toy on every hand - better, more than one toy on every hand - best. This is already a kind of math, a simplified description of the Peano axioms as we can transform this into a simple inequality, replacing the term 'is worse than' and 'is better than' by the relational operators '<' and '>'.

or even simpler

In the end the child only needs to be able to distinguish between one and more than one objects, only the comparison operators '=" and '≠' are necessary. Everything else can be learned and then unknown substituted by learned. If the child has for instance already learned that 1+1=2 and 1+2=3, '2' can be replaced by '1+1'. It isn't necessary to know anything about the arithmetic operator '+'. '1+1' can just be seen as a set of objects which is equal to '2'. Now '2' can be substituted by '1+1' and the second equation becomes 1+1+1=3.

Based on this assumption I started to develop a program in Arduino C that should learn to add two integers *a* and *b*, where 1 ≤ *a*;*b* ≤ 5. The program contans following parts:

*Supervised learning algorithm*. A teacher tags randomly generated equations as true or false via keyboard. False equations will be not repeated. If an equation*a*+*b*=c (e.g. 1+5=6) was tagged as true, the randomly generated values for the variables*a*and*b*(e.g. 1 and 5) will be not repeated as well to speed up the learning progress.*Substitution*. All integers are substituted by additions of ones, e.g. if 1+1=2 and 1+2=3 then 1+1+1=3.*Random example generator*. Generates 5 times random numbers for the summands*a*and*b*, after the substituation of the integers 1 to 10 is completed.*Adder*. Stores the two randomly generated summands in an array, e.g. 5 and 3: sum array={1,1,1,1,1,1,1,1,0,0}.*Comparator.*Compares the sum array via if statements with all substituted integers and ouputs the result via serial monitor.

I have attached the code as a ZIP file. If you want to watch the video, please chose video quality 480p.

Next step is to replace the keyboard by two push buttons and the serial monitor by the Parallax Emic 2 Text-to-Speech Module, which I should get in the mail when I am returning from Thailand, Phuket.

Attachment | Size |
---|---|

Math_machine_learning.zip | 3.06 KB |

## ok question here

Ok let see If I unsterstood the concept ,someone puts an equation of 2 integers in the serial monitor screen you have there

the programm creates 2 random integers everytime til the equation is true if it finds it is true it ignores the a,b that made it true

and continue to other equation?Is that right ?If not please explain a bit more because It seems very interesting to me .

## No, the equations are

No, the equations are randomly generated and then displayed via serial monitor. You just need to send 'y' for 'yes' or 'n' for 'no' via serial monitor after an equation is shown. If an equation was tagged with 'y' or 'n' it will not be repeated anymore. After the program has learned that a certain set of equations is true, the substitution starts. Substitution means the program generalize the gained knowledge. After that the program is able to do additios by itself. The program has so to say learned how to add two integers.

## Wow Markus, you are a good

Wow Markus, you are a good observer and even better documenter. I observed those behavior too but never get the idea to write a program about that :-)

As soon as I have time I need to check this program and try to find a good use for it.

## They collect into their teens

My daughter is13 and I still follow her around gathering things up. She randomly moves things are takes things she thinks she might use. She has an interest in the robot parts in that they are good for drawing practice because of all the edges. Finished robots also disappear to have string and feather attached so the cats can follow them around.

Good Luck

Shon