Advertisement
Scali_e

Pull

Mar 3rd, 2015
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | None | 0 0
  1. print("pull")
  2.  
  3. sleep(1)
  4.  
  5. n = 0
  6. sum = 0
  7. time = 0
  8.  
  9. local vari = {}
  10.  
  11.  while true do
  12.  
  13.   os.pullEvent("redstone")
  14.   y = os.clock() - time
  15.   local time = os.clock()
  16.  
  17.   os.pullEvent("redstone")
  18.   x = os.clock() - time
  19.   --print("t: "..x)
  20.   local time = os.clock()
  21.  
  22.   sum = x+sum
  23.   n = n+1
  24.   table.insert(vari,x)
  25.   med = sum/n
  26.  
  27.   print("t: "..x.." med: "..med.."  n: "..n)
  28.  
  29.   if n > 3 then
  30.    if med < 0.2 then
  31.     break
  32.    end
  33.   end
  34.  
  35.  end
  36.  
  37. sum2 = 0
  38. n2 = table.getn(vari)
  39.  
  40. for i=1,n2 do
  41. sum2 = sum2+math.pow(vari[i]-med,2)
  42. end
  43. s = math.sqrt((1/n)*sum2)
  44.  
  45. term.clear()
  46. term.setCursorPos(1,1)
  47. print("data")
  48. print("t: "..x.." med: "..med.." n:"..n)
  49. print("s: "..s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement