code: import math
  import numpy as np
  import numpy as np
  import matplotlib.pyplot as plt
  from mpl_toolkits.mplot3d import Axes3D
  
  from matplotlib import pyplot as pb
  import random
  from datetime import datetime
  import time
  import sys
  import csv
  
  
  def dist(x, y, pos):
      return math.sqrt((pos[0]-x)**2 + (pos[1]-y)**2)
  
  areaSize=(4, 4)
  node_pos = [(0,0),(0,4),(4,0)]
  
  if 'wifi' in sys.argv[1]:
      rss0 = -45.73
      pathloss_exponent = 2.162
  elif 'ble' in sys.argv[1]:
      rss0 = -75.48
      pathloss_exponent = 2.271 
  elif 'zigbee' in sys.argv[1]:
      rss0 = -50.33
      pathloss_exponent = 2.935
  
  def gen_wifi(freq=2.4, power=20, trans_gain=0, recv_gain=0, size=areaSize, pos=(5,5), shadow_dev=1, n=pathloss_exponent,noise=1):
      if pos is None:
          pos = (random.randrange(size[0]), random.randrange(size[1]))
  
      random.seed(datetime.now())
  
      normal_dist = np.random.normal(0, shadow_dev, size=[size[0]+1, size[1]+1])
      rss = []
  
      random.seed(datetime.now())
  
      for x in range(0,3):
          distance = dist(node_pos[x][0], node_pos[x][1], pos)
          val =rss0 - 10 * n * math.log10(distance) + normal_dist[int(pos[0])][int(pos[1])]
          rss.append(val-noise*random.random())
  
      return rss
  
  
  with open(sys.argv[1]) as f:
      dict_from_csv = [{k: v for k, v in row.items()}
          for row in csv.DictReader(f, skipinitialspace=True)]
  
  overall_rss=[]
  original_tragectory=[]
  
  for i in range(len(dict_from_csv)):
      dict=dict_from_csv[i]
      x , y = float(dict['x']) , float(dict['y'])
      original_tragectory.append((x,y))
      random.seed(datetime.now())
      rss = [-int(float(dict['RSSI A']))-random.random(),-int(float(dict['RSSI B']))-random.random() ,-int(float(dict['RSSI C']))-random.random()]
      overall_rss.append(rss)
  
  
  
  random.seed(datetime.now())
  previous_errors =[]
  distance_error =[]
  particles = []
  
  start_time = time.time()
  for x in np.arange(0.1,areaSize[0]-1,0.2):
      for y in np.arange(0.1,areaSize[1]-1,0.2):
          particles.append((x,y))
  
  for i in range(0,len(original_tragectory)):
      positions =[]
      errors=[]
      error=0
      for particle in particles:
          x,y=particle[0],particle[1]
          actual_rss = gen_wifi(pos=(x,y),noise=0)
          error=np.sum(np.subtract(actual_rss,overall_rss[i]))
      
          positions.append((x,y))
          errors.append(error)
  
  
      min_error = min(errors)
      min_index = errors.index(min_error)
      pos=positions[min_index]
      previous_errors.append(errors[min_index])
      distance_error.append(dist(pos[0],pos[1],original_tragectory[i]))
  
  
  
  print("--- Computation Time: %s seconds ---" % (time.time() - start_time))
  distcumulativeEror=np.sum(distance_error)
  distmeanError=np.average(distance_error)
  distStandardDeviationError=np.std(distance_error)
  print("DIST_ERROR:   Cummulative Error: " + str(distcumulativeEror)+"\tMean  Error: "+str(distmeanError)+"\tStandard Deviation: "+str(distStandardDeviationError))
  
  
  
apis: numpy.sum numpy.subtract numpy.arange numpy.random.normal numpy.std numpy.average