<jupyter_start><jupyter_text>Measure noise performance of sheaf-based transmitter locating(c) 2019 <NAME><jupyter_code>from generate_data import *
import fox_sheaf as fs
import numpy as np
import pysheaf as ps
import matplotlib.pyplot as plt
import copy<jupyter_output><empty_output><jupyter_text>Basic simulation parameters<jupyter_code>ntrials=5 # Number of trials to run for data

noise_devs=np.linspace(0.00000001,0.01,20) # Noise deviation
angle_devs=np.linspace(0.01,10.0,20) # Angle deviation (degrees)<jupyter_output><empty_output><jupyter_text>Transmitter is in a fixed location, along with three receivers, also at fixed locations.  Note that we do not yet generate `Receiver` instances for the receivers.  We'll do that later!<jupyter_code>txA=Transmitter(location=np.array([0.5,0.5]),power=1.0,identity='A')

rx1_location=np.array([1.0,0.0])
rx2_location=np.array([1.0,1.0])
rx3_location=np.array([0.0,0.0])
rx4_location=np.array([0.0,0.5])
rx_types=['bearing','bearing','rssi','rssi']<jupyter_output><empty_output><jupyter_text>Performance under simulated noisy RSSI measurementsWe'll build a fresh set of receivers for each trial of the simulation.  As a result, we also build a fresh sheaf for each trial. Preallocate arrays to store the results of all trials<jupyter_code>crs_noise_post=np.zeros([len(noise_devs),ntrials])
nn=np.zeros([len(noise_devs),ntrials])
errors_noise_extended=np.zeros([len(noise_devs),ntrials])<jupyter_output><empty_output><jupyter_text>Run the simulation!<jupyter_code>for k in range(nn.shape[0]):
    noise_dev=noise_devs[k]
    for m in range(nn.shape[1]):
        print('{} % complete: Trial {} of {}, noise {} of {}'.format(int(100*((m+k*nn.shape[1])/(ntrials*(len(noise_devs)+len(angle_devs))))),m+1,nn.shape[1],k+1,nn.shape[0]))
        
        nn[k,m]=noise_dev
        
        # Case 1
        rx1=Receiver(rx_noise_level=noise_dev,rx_antenna_beamwidth=angle_devs[0])
        rx1.name='1'
        rx1.add_reception(time=0.0,location=rx1_location,transmitter=txA)
        
        rx2=Receiver(rx_noise_level=noise_dev,rx_antenna_beamwidth=angle_devs[0])
        rx2.name='2'
        rx2.add_reception(time=0.0,location=rx2_location,transmitter=txA)
        
        rx3=Receiver(rx_noise_level=noise_dev,rx_antenna_beamwidth=angle_devs[0])
        rx3.name='3'
        rx3.add_reception(time=0.0,location=rx3_location,transmitter=txA)
        
        rx4=Receiver(rx_noise_level=noise_dev,rx_antenna_beamwidth=angle_devs[0])
        rx4.name='4'
        rx4.add_reception(time=0.0,location=rx4_location,transmitter=txA)

        rxs=[rx1,rx2,rx3,rx4]
        
        sheaf=fs.FoxSheaf(rx_types,rxs)
        
        sheaf.FuseAssignment()

        # Record the consistency radius
        crs_noise_post[k,m]=sheaf.ComputeConsistencyRadius()
        
        # Record the error in fox location
        errors_noise_extended[k,m]=np.linalg.norm(sheaf.GetCell(1).mDataAssignment.mValue-txA.location)<jupyter_output>0 % complete: Trial 1 of 5, noise 1 of 20
0 % complete: Trial 2 of 5, noise 1 of 20
1 % complete: Trial 3 of 5, noise 1 of 20
1 % complete: Trial 4 of 5, noise 1 of 20
2 % complete: Trial 5 of 5, noise 1 of 20
2 % complete: Trial 1 of 5, noise 2 of 20
3 % complete: Trial 2 of 5, noise 2 of 20
3 % complete: Trial 3 of 5, noise 2 of 20
4 % complete: Trial 4 of 5, noise 2 of 20
4 % complete: Trial 5 of 5, noise 2 of 20
5 % complete: Trial 1 of 5, noise 3 of 20
5 % complete: Trial 2 of 5, noise 3 of 20
6 % complete: Trial 3 of 5, noise 3 of 20
6 % complete: Trial 4 of 5, noise 3 of 20
7 % complete: Trial 5 of 5, noise 3 of 20
7 % complete: Trial 1 of 5, noise 4 of 20
8 % complete: Trial 2 of 5, noise 4 of 20
8 % complete: Trial 3 of 5, noise 4 of 20
9 % complete: Trial 4 of 5, noise 4 of 20
9 % complete: Trial 5 of 5, noise 4 of 20
10 % complete: Trial 1 of 5, noise 5 of 20
10 % complete: Trial 2 of 5, noise 5 of 20
11 % complete: Trial 3 of 5, noise 5 of 20
11 % complete: Trial 4 of 5, no[...]<jupyter_text>Plot the consistency radius<jupyter_code>maxcr=0.1
plt.figure()
plt.plot(nn.flatten(),crs_noise_post.flatten(),'.',markersize=10)
plt.ylim([0,maxcr])
plt.xlabel('Noise deviation')
plt.ylabel('Consistency radius')
plt.title('Noise-induced inconsistency')<jupyter_output><empty_output><jupyter_text>Plot the fox location error<jupyter_code>plt.figure()
plt.plot(nn.flatten(),errors_noise_extended.flatten(),'g^',markersize=10)
plt.ylim([0,2])
plt.xlabel('Noise deviation')
plt.ylabel('Location error')
plt.title('Location errors after filtering')<jupyter_output><empty_output><jupyter_text>Performance under simulated noisy bearing measurementsThe RSSI measurements are without noise, and this goes much as above! Preallocate arrays for the results<jupyter_code>crs_angle_post=np.zeros([len(angle_devs),ntrials])
aa=np.zeros([len(angle_devs),ntrials])
errors_angle_extended=np.zeros([len(noise_devs),ntrials])<jupyter_output><empty_output><jupyter_text>Run the simulation<jupyter_code>for k in range(aa.shape[0]):
    angle_dev=angle_devs[k]
    for m in range(aa.shape[1]):

        print('{} % complete: Trial {} of {}, angle {} of {}'.format(int(100*((m+k*aa.shape[1]+ntrials*len(noise_devs))/(ntrials*(len(noise_devs)+len(angle_devs))))),m+1,aa.shape[1],k+1,aa.shape[0]))
        
        aa[k,m]=angle_dev
        # Case 1
        rx1=Receiver(rx_antenna_beamwidth=angle_dev)
        rx1.name='1'
        rx1.add_reception(time=0.0,location=rx1_location,transmitter=txA)
        
        rx2=Receiver(rx_antenna_beamwidth=angle_dev)
        rx2.name='2'
        rx2.add_reception(time=0.0,location=rx2_location,transmitter=txA)
        
        rx3=Receiver(rx_antenna_beamwidth=angle_dev)
        rx3.name='3'
        rx3.add_reception(time=0.0,location=rx3_location,transmitter=txA)
        
        rx4=Receiver(rx_antenna_beamwidth=angle_dev)
        rx4.name='4'
        rx4.add_reception(time=0.0,location=rx4_location,transmitter=txA)
        
        rxs=[rx1,rx2,rx3,rx4]
        
        sheaf=fs.FoxSheaf(rx_types,rxs)
        
        sheaf.FuseAssignment()

        # Record the consistency radius
        crs_angle_post[k,m]=sheaf.ComputeConsistencyRadius()
        
        # Record the error in fox location
        errors_angle_extended[k,m]=np.linalg.norm(sheaf.GetCell(1).mDataAssignment.mValue-txA.location)<jupyter_output>50 % complete: Trial 1 of 5, angle 1 of 20
50 % complete: Trial 2 of 5, angle 1 of 20
51 % complete: Trial 3 of 5, angle 1 of 20
51 % complete: Trial 4 of 5, angle 1 of 20
52 % complete: Trial 5 of 5, angle 1 of 20
52 % complete: Trial 1 of 5, angle 2 of 20
53 % complete: Trial 2 of 5, angle 2 of 20
53 % complete: Trial 3 of 5, angle 2 of 20
54 % complete: Trial 4 of 5, angle 2 of 20
54 % complete: Trial 5 of 5, angle 2 of 20
55 % complete: Trial 1 of 5, angle 3 of 20
55 % complete: Trial 2 of 5, angle 3 of 20
56 % complete: Trial 3 of 5, angle 3 of 20
56 % complete: Trial 4 of 5, angle 3 of 20
56 % complete: Trial 5 of 5, angle 3 of 20
57 % complete: Trial 1 of 5, angle 4 of 20
57 % complete: Trial 2 of 5, angle 4 of 20
58 % complete: Trial 3 of 5, angle 4 of 20
59 % complete: Trial 4 of 5, angle 4 of 20
59 % complete: Trial 5 of 5, angle 4 of 20
60 % complete: Trial 1 of 5, angle 5 of 20
60 % complete: Trial 2 of 5, angle 5 of 20
61 % complete: Trial 3 of 5, angle 5 of 20
61 % comple[...]<jupyter_text>Plot the consistency radii<jupyter_code>plt.figure()
plt.plot(aa.flatten(),crs_angle_post.flatten(),'.',markersize=10)
plt.ylim([0,maxcr])
plt.xlabel('Angle deviation (deg)')
plt.ylabel('Consistency radius')
plt.title('Angle-induced inconsistency')<jupyter_output><empty_output><jupyter_text>Plot the fox location errors<jupyter_code>plt.figure()
plt.plot(aa.flatten(),errors_angle_extended.flatten(),'g^',markersize=10)
plt.ylim([0,2])
plt.xlabel('Angle deviation (deg)')
plt.ylabel('Location error')
plt.title('Location errors after filtering')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1204743282452378, 'fraction_numerical': 0.05916487952567175, 'mean_word_length': 4.364005412719892, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '222646', 'license': 'MIT', 'n_tokens_mistral': 3293, 'n_tokens_neox': 2832, 'n_words': 756, 'path': 'noise_performance.ipynb', 'repo_name': 'kb1dds/foxsheaf', 'size': '7937'}