User:Kithira/Course Pages/CSCI 12/Assignment 2/Group 1/Homework 4: Difference between revisions

Content deleted Content added
Code:: edited programs
m Replaced deprecated <source> tags with <syntaxhighlight>
 
(4 intermediate revisions by 2 users not shown)
Line 1:
==Final Project ==
'''by: Christopher Chandler, Ashley Kim, Marina Chaves Caldieraro=='''
 
==== Code:Summation Program plus Filter ====
<sourcesyntaxhighlight lang="python">
 
<source lang="python">
from math import sqrt, pow
def summarize(x, y, z):
sumT = 0
val1 = 0
for i in range(40):
sumTval2 = sumT + abs(sqrt(pow(x,2)+pow(y,2)+pow(z,2))-1.0)
if abs(val2 - if resval1) > 5.02:
resval2 = 0val1
sumT = sumT + val2
val1 = val2
return sumT
</syntaxhighlight>
</source>
 
This code represents the function Summarize, which summarizes theeach quarter secondsinput using <math>|(\sqrt ({x^2 + y^2 + z^2)}{-1}|</math>. Then, these values are summarized for ''i in range(40)'', which gives a value for 1 minutesecond. To prevent against data spikes the programs checks the difference between the previous value and the current value, and if the difference is greater than 2 it replaces the current value with the previous value.
 
==== Core Program ====
This code represents the function Summarize, which summarizes the quarter seconds using |(sqrt (x^2 + y^2 + z^2)-1|. Then, these values are summarized for i in range(40), which gives a value for 1 minute.
 
<sourcesyntaxhighlight lang="python">
def getData(file):
infile = open(file)
Line 27 ⟶ 34:
row = line.split(",")
res = summarize(float(row[1]), float(row[2]), float(row[3]))
if res > 5.0:
res = 0
lis = lis + res
ave = lis/60.0
Line 34 ⟶ 39:
return total
print getData("/usr/local/share/cs12/Test1.csv")
</syntaxhighlight>
</source>
 
The second part of code is responsible for averaging the values over a minute then adding all the minutes over the course of a week to find a total result that determines the intensity classification. The filter we used deletes any value above 5.0 per minute. We determined this boundary value based off of the plot of the original summarized data over 10 hours. The range of 24192000 represents the total seconds in a week. Finally, we determined that our test subject was a moderately active person.