How to calculate the inter distance between consecutive random numbers?

조회 수: 6 (최근 30일)
Ricky Stevens
Ricky Stevens 2016년 7월 29일
댓글: Ricky Stevens 2016년 7월 29일
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
James Tursa 2016년 7월 29일
Have you written any code so far? How is your iteration data currently organized?
Ricky Stevens
Ricky Stevens 2016년 7월 29일
The data would be a bunch of randomly generated events that I want to produce in MATLAB. I will need to use a min, max coordinate for space, and a min, max time for time. Then I want the inter distances between all possible pairs of events, separately for space, and for time.
My field data on the other hand is in Excel. I have two columns. Column One, event timing, Column Two, event coordinate.
I have never written code before. I am new to Matlab. So this is a first for me. I try to do this task in Excel manually but to do this 1000 times over I will be here for months!

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
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.
To learn MATLAB, check out this link.
  댓글 수: 1
Ricky Stevens
Ricky Stevens 2016년 7월 29일
Thank you user = Image Analyst for your quick response. I'm just reading over the pdf you attached.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by