+ Reply to Thread
Results 1 to 3 of 3

Need to calculate the difference between different pairs of values

  1. #1
    Registered User
    Join Date
    03-04-2008
    Posts
    3

    Need to calculate the difference between different pairs of cells

    Hello!

    I have a column with 20 integers, from 1 to 20. Each integer is associated with a value in a second column.

    These integers represent 20 evenly spaced points along a circle. Points 1 and 20 are therefore close together, whereas points 1 and 10 are maximally separated.

    I need to calculate the difference between the recorded values in the second column for every possible combination of lag distances! Namely,
    points with a lag distance of 1 would include (1,2) (2,3) (3,4) (4,5) ... (20,1)
    points with a lag distance of 2 would include (1,3) (2,4) (3,5) (4,6) (5,7) ... (20,2)
    points with a lag distance of 10 (maximal distance!) would include (1,10) (2,11) (3,12) (4,13) ... (20,10)

    For each calculated difference I would also need to know which lag I'm referring to (1,2, ... 10), perhaps listed in another column.

    Thank you!

    Ilford
    Last edited by Ilford; 03-22-2008 at 01:18 AM.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    So, you have a circle of radius R and and 20 points evenly spaced along the circumference of the circle. Assuming that p(1)<>p(20), the angular seperation between p(i) and p(i+1) is 2*PI/21. Let's call that angle a.

    The linear distance between p(i) and p(i+j) is the distance between the points

    (R*cos(j*a),R*sin(j*a)) and (R,0) which is

    R * sqrt( (cos(j*a)-1)^2 + sin(j*a)^2)

    = R * sqrt (cos(ja)^2 - 2*cos(ja) + 1 +sin(ja)^2)

    =R * sqrt(2 - 2*cos(j*a)).

    I think j is what you call the "lag".
    Last edited by mikerickson; 03-22-2008 at 01:43 AM.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    03-04-2008
    Posts
    3

    Smile

    Hi, and thanks for your great reply.

    However, I don't need to calculate any angles. I only require a formula (or set of formulae) to calculate the difference between the values for a given pair of points.

    The pairs of points are defined by their lag distance; in other words, the number of points separating them.

    E.g., For a lag distance of one, I would need the difference of the values found between all combinations of points that are separated by one point (1and2; 2and3; 3and4 ... 20and1). For a lag distance of two I would need the difference of the values found between all combinations of points that are separated by two points (1and3; 2and4; 3and5 ... 20and2), and so forth until you reach the maximum lag distace of 10.

    point value
    1 0.394
    2 0.998
    3 0.102
    4 0.432
    ...
    20 0.595


    Thanks again!!

    Ilford
    Last edited by Ilford; 03-22-2008 at 10:53 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1