Creative Communications

22 June, 2010

Brain Training, Data Capture and Simple Math Problems

Filed under: Life Management — admin @ 10:00 pm

Personal Data Monitoring has been eeking into the public sphere of awareness. The basic idea is that if you can quantify information about your life, and adjust your input parameters, you can discover correlations you would otherwise miss, due to the frailty of subjective memory.

Brain Training is another facet which you’ve probably heard of incorporated in video games like “Brain Age“. We build our neural connections through use, hence the more you exercise your brain, the better it gets, according to the ideas of brain training.

Somewhere in my reading about this, I heard about someone who wrote a small program to test their math skills every day. They discovered a correlation between flax seed oil and higher cognitive performance. Wow! Yet, a casual google search turned up nothing so far as software.

I’ve been meaning to pick up a little Python, and here is my attempt to duplicate this program. Basically it asks you 30 simple math questions, times you and displays your score.

#!/usr/bin/env python
# encoding: utf-8
- inspired by some brain training / data measurement
Created by Sean Canton on 2010-06-22.
Copyright (c) 2010 All rights reserved.

import sys
import os
import math
import random
import time


timetally = 0
correct = 0
wrong = 0

for i in range(0, NUM_TRIALS):
start = time.time()
a = random.randint(0,10)
b = random.randint(0,10)
op = random.randint(0,2)
d = {0:"+", 1:"-", 2:"*"}
op = d.get(op)
s = str(a) + op + str(b)
a = raw_input(s + " = ")
#print 'Code: ' + str(s)
# print 'Ans: ' + str(eval(s))
# print 'Yours: ' + str(a)
finish = math.floor((time.time() - start)*100)/100
timetally += finish

if a == str(eval(s)):
#print 'true'
#print finish
correct += 1
elif a != str(eval(s)):
#print 'false'
wrong += 1
#print finish

perc = correct/float(NUM_TRIALS)

perc *= 100
print "time: " + str(timetally)
print "right : " + str(correct)
print "wrong :" + str(wrong)
print "% : " + str(perc)

As you can see, it’s fairly straightforward. .get is a dictionary method that returns the value from the key value pairs in variable d. Python doesn’t have a switch/case function, and I have to say, the dictionary way of doing things is much cleaner.

I’m looking forward to diving into more Python experiments. I’ll keep you all posted.

Powered by WordPress