How to calculate the inter distance between consecutive random numbers?
조회 수: 6 (최근 30일)
이전 댓글 표시
dear MATLAB community,
I need to run 1000 iterations of 100 randomly generated synthetic events in space, and in time, and record the inter distances between all possible pairs, i.e.,.
1-2, 1-3, 1-4, 1-100, (space) and (time)
2-3, 2-4, 2-5, 2-100,
and so on eventually to 99 - 100
The plan is to run a students t test to compare the standard deviation of the synthetic events inter distances in space-time, against the inter distances in space-time for data collected from the field. We think spatial temporal clustering exists in our real world data and we want to find out if our data is statistically significant from clustering that can occur in a bunch of random numbers.
I am a MATLAB beginner, not shy of hard work, but I do not know how to write code. I'm wanting and willing to learn and would really appreciate any help with getting this sorted out in MATLAB,
Thank you very much in advance for any help that is offered, R
댓글 수: 2
James Tursa
2016년 7월 29일
Have you written any code so far? How is your iteration data currently organized?
답변 (1개)
Image Analyst
2016년 7월 29일
편집: Image Analyst
2016년 7월 29일
Sounds like an assignment. Here's a hint (required the Statistics and Machine Learning Toolbox for the pdist2() function).
numPoints = 100 % Whatever you want.
% Get list of numPoints randomly placed (x,y) coordinates.
xy = rand(numPoints, 2);
% Get distances from every point to every other point.
distances = pdist2(xy, xy)
Put this in a loop to do it 1000 times. Also do your t-test inside the loop.
Standard deviation of distances is not a good metric for determining interdependence of points. You might take a look at the "bible" of spatial statistics: http://umaine.edu/computingcoursesonline/files/2011/07/SpatstatmodelingWorkshop.pdf
Take a look at chapter 1, and also on page 114 where they discuss interdependence of points and Morishita plots (based on chi squared), and Fry plots. Then check out Page 125 for Ripley's K function which characterizes the pairwise distances.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!