Advertisement
Guest User

Untitled

a guest
Nov 4th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1.  
  2.  
  3. ##Justin Beitz
  4. ##Assignment 3
  5.  
  6. unless ARGV[0].to_s == "input.txt"
  7. puts "Wrong input"
  8. end
  9.  
  10. unless ARGV[1].to_s == "output.txt"
  11. puts "Wrong output"
  12. end
  13.  
  14.  
  15. input = ARGV[0].to_s
  16. output = ARGV[1].to_s
  17.  
  18. inFile = File.new('input.txt', 'r')
  19.  
  20.  
  21. def createArray
  22.  
  23. rowData = inputFile.split(', ')
  24. rowReturn = Hash.new
  25. rowReturn
  26. end
  27.  
  28. def calcAverage
  29.  
  30. average = array.reduce(:+) / array.size.to_f
  31.  
  32. end
  33.  
  34. def calcStandardDeviation
  35.  
  36. sum = array.inject(0){|accum, i| accum +(i-average)**2 }
  37. deviation = sum/(array.length - 1).to_f
  38. deviation = Math.sqrt(deviation)
  39.  
  40. end
  41.  
  42. def calcMedian
  43.  
  44. sorted = array.sort
  45. len = sorted.length
  46. median = (sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0
  47.  
  48. end
  49.  
  50. def fileIO
  51.  
  52. File.open('input.txt', 'r')
  53.  
  54. inFile.each_line do |line|
  55. lineString = line.to_s
  56. lineSplit = lineString.split(" ")
  57.  
  58. end
  59. inFile.close
  60.  
  61.  
  62.  
  63. outFile = File.new("output.txt", 'w')
  64.  
  65. outFile.print(x.to_s + " " )
  66. end
  67. outFile.close()
  68.  
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement