0

I am trying to build malicious ATM activity detection I have a function that takes 4 parameters( old_latitude,old_longitude,new_latitude,new_longitude) and it returns distance between two points and I have two time stamps one having latest time stamps and the other having a timestamp just happened.I am trying to detect that it is possible to access ATM machine. So I am thinking of dividing distance(km) by speed of flight(km) and compare time if the result is different from time it is long. how am i supposed to write a code in python?

I Worte a code

    time_diff=new_time_stamp-old_time_stamp,
    time_speed=(time_diff/3600)*1000
    if distance <= time_speed:
       print "no malicious activity"
    else:
       print "malicious activity detected"
user1413449
  • 1,043
  • 1
  • 7
  • 12
  • How can you be sure that the two ATMs times are accurate enough to compare? ATM_1 might tell you the current time is 2:34.12345, but ATM_2 might tell you the current time is 2:34.12350. Keeping multiple machines synchronized is somewhat solved, but not at the accuracy you need to do this. – 000 Jun 11 '13 at 18:36
  • It is a school project and nothing related to business – user1413449 Jun 11 '13 at 19:03
  • The question says they are trying to build malicious ATM activity detection. – 000 Jun 11 '13 at 19:05
  • You probably either want `from __future__ import division` or change `3600` to `3600.0`. – Mark Ransom Jun 11 '13 at 19:05
  • I guess I also misread the question. It said speed of flight but I read speed of light. – 000 Jun 11 '13 at 19:06
  • Use this answer for the Haversine formula in python http://stackoverflow.com/questions/4913349/haversine-formula-in-python-bearing-and-distance-between-two-gps-points – Vorsprung Jun 11 '13 at 19:31
  • So, what happens if I go to one ATM that reads local time 1:34, then walk across the street, which just so happens to have a time zone line running down the center of it, and the next ATM, a mere 5 minutes later, gives me a local time of 12:34? (i.e. I presume you want UTC times here...). Also note that speed is usually distance/time, not time/something*something_else (i.e. not sure what the variable name `time_speed` is supposed to signify - it looks like thousandths of an hour, but that has nothing to do with speed...). – twalberg Jun 11 '13 at 19:40

1 Answers1

0

Also read it as speed of light at first, but it is obviously just checking if the same card is being used at different locations that are so far apart that they cannot be reached by flight in the intervening time. you had mostly correct code already

flight_speed = 1000   #km/h assumed
time_diff = 4000      #assumption seconds
secs_per_hour = 60*60
possible_distance_travelled = time_diff / secs_per_hour * flight_speed   # in km
if distance_between_ATMs < possible_distance_travelled:
print "no malicious activity"
    else:
print "malicious activity detected"

Not sure if simple homework problems should be answered here

Joop
  • 7,840
  • 9
  • 43
  • 58