Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

5. Enabling mHealth for Quantified Self > What About Android and iOS? - Pg. 92

Example 5-13. Algorithm for calculating mood, stress, and well-being over the past month /* * Algorithm * 1. Read last 1 month's readings * 2. Weight 50% to 4th week * 3. Weight 25% to 1-3 week * 4. Weight 25% to how many readings (Good is 4/wk) */ DateTime time50p = baseTime.Subtract(new TimeSpan(7,0,0,0)); DateTime time30p = baseTime.Subtract(new TimeSpan(14, 0, 0, 0)); int m = 0; int s = 0; int w = 0; int c50 = 0; int c30 = 0; int c20 = 0; foreach (EmotionalStateModel emotion in emotionList) { if (emotion.When >= time50p) { m += (int)emotion.Mood * 50 ; s += (int)emotion.Stress * 50 ; w += (int)emotion.Wellbeing * 50; c50++; } else if (emotion.When >= time30p) { m += (int)emotion.Mood * 30; s += (int)emotion.Stress * 30 ; w += (int)emotion.Wellbeing * 30; c30++;