1 function [ros,ros_mean] = ros_variance(n,ps)
2 %estimates variance in ros between two detections
3 %n - number of random points to use in simulation
4 %ps - struct with path information, ps = cluster_paths(w,1)
6 real_data = input_num('Use real data? 0 = no 1 = yes',1,1);
9 %coordinates of detections
14 dist_r = sqrt((d2(1)-d1(1))^2+(d2(2)-d1(2))^2);
15 time_r = d2(3) - d1(3);
17 fprintf('ROS = %f\n',ros)
29 num_paths = length(ps.paths);
30 path_num = max(2,round(num_paths*rand));
31 p = ps.paths(path_num);
32 path_length = length(p);
33 path_end = max(2,round(path_length*rand));
34 p1 = p.p(path_end -1);
36 fprintf('Generating stats for path %d, points %d and %d \n',path_num,path_end-1,path_end);
37 lon1 = ps.points(p1,2);
38 lat1 = ps.points(p1,1);
39 time1 = ps.points(p1,3);
40 lon2 = ps.points(p2,2);
41 lat2 = ps.points(p2,1);
42 time2 = ps.points(p2,3);
45 dist_r = distance(lat1,lon1,lat2,lon2,E);
52 ros = dist_r/(time_r*24*3600);
53 fprintf('Dist = %f m Time = %f s \n',dist_r,time_r*24*3600);
54 fprintf('ROS = %f m/s \n',ros)
56 %coordinates of detections
58 d2 = [0 dist_r time_r];
64 end %if real_data == 0
69 r1 = sig1*randn(n,3)+d1;
70 r1(:,3) = d1(3)-time_diff*rand(n,1);
71 r2 = sig2*randn(n,3)+d2;
72 r2(:,3) = d2(3)-time_diff*rand(n,1);
75 dist_rand = sqrt(dr(:,1).^2+dr(:,2).^2);
78 ros_rand = dist_rand./time_rand;
80 ros_rand = dist_rand./(24*3600*time_rand);
83 figure,scatter3(r1(:,1),r1(:,2),r1(:,3),'*b')
84 xlabel('x'),ylabel('y'),zlabel('time')
85 title('Random paths between two detections')
87 scatter3(r2(:,1),r2(:,2),r2(:,3),'*r')
89 plot3([r1(i,1) r2(i,1)],[r1(i,2) r2(i,2)],[r1(i,3) r2(i,3)],':')
93 figure,scatter3(dist_rand,1./time_rand,ros_rand);
94 xlabel('Distance'),ylabel('1/Time'),zlabel('ROS')
97 figure,histogram(ros_rand)
99 title('Histogram of ROS')
101 t_str = sprintf('Histogram of ROS \n Path: %d Points: %d and %d',path_num,path_end-1,path_end);
102 t_str2 = sprintf('Distance: %f [m] Time: %f [h]',dist_r,time_r*24)
103 title({t_str,t_str2})
105 xlabel('ROS'),ylabel('Number')
106 ros_mean = mean(ros_rand);
107 fprintf('Mean random ROS: %f m/s \n',ros_mean)
108 ros_std = std(ros_rand);
109 fprintf('Standard deviation of random ROS: %f m/s \n',ros_std)
111 figure,qqplot(ros_rand)