MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: modified list interval calculation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21152] Re: [mg21058] Re: modified list interval calculation
  • From: "David Park" <djmp at earthlink.net>
  • Date: Fri, 17 Dec 1999 01:22:07 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Deborah,

Here is one method:
t = {1, 4, 4.5, 6, 7, 8, 8.9, 9, 10, 12, 140, 16, 16.8, 17, 18, 19, 19.1, 
      19.3, 19.5, 20};
nt = {8, 8.9, 10, 17};

pairs = Transpose[{Drop[t, 1], Drop[t, -1]}]
{{4, 1}, {4.5, 4}, {6, 4.5}, {7, 6}, {8, 7}, {8.9, 8}, {9, 8.9}, {10, 9}, {12,
     10}, {140, 12}, {16, 140}, {16.8, 16}, {17, 16.8}, {18, 17}, {19, 
    18}, {19.1, 19}, {19.3, 19.1}, {19.5, 19.3}, {20, 19.5}}

Select[pairs,  !(MemberQ[nt, #1[[1]]] || 
     MemberQ[nt, #1[[2]]]) & ]
(Subtract @@ #1 & ) /@ %
{{4, 1}, {4.5, 4}, {6, 4.5}, {7, 6}, {140, 12}, {16, 140}, {16.8, 16}, {19, 
    18}, {19.1, 19}, {19.3, 19.1}, {19.5, 19.3}, {20, 19.5}}
{3, 0.5, 1.5, 1, 128, -124, 0.8, 1, 0.1, 0.2, 0.2, 0.5}

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

>Hi,
>I am having trouble with the problem below:
>
>I am trying to remove from list, t, those numbers in list, nt, that 
>match and then I want to calculate the differences (intervals ) 
>between succesive numbers in list, t, that do not contain the 
>removed number. For example:
>the two lists are;
>t = {1,4,4.5,6,7,8,8.9,9,10,12,140,16,16.8,17,18,
> 19,19.1,19.3,19.5,20}
>nt = {8,8.9,10,17}
>
>the resulting intervals would look like:
>4 -1, 4.5 - 4, 6 - 4.5, 7 - 6, 140 -12, 16 - 140, 16.8 - 16, 19 - 18,
>19.1 -19, 19.3 - 19.1, 19.5 - 19.3, 20 - 19.5
>and of course the final list would be:
>intervals = {3, .5, 1.5, 1, 128, -124, .8, 1, .1, .2, .2, .5};
>
>Note that 9 was omitted from the calculation of intervals because it 
>would have been involved in a calculation with a removed number 
>from the list, t. 
>
>Thanks in advance if anyone can help.
>
>Regards, Debbie
>
>
>



  • Prev by Date: Re: Mathematica and Topology.
  • Next by Date: Re: Q: efficient in-place list element replacement?
  • Previous by thread: Re: Re: modified list interval calculation
  • Next by thread: Re: Re: modified list interval calculation