Re: Fastest method for comparing overlapping times in random time series

*To*: mathgroup at smc.vnet.net*Subject*: [mg64965] Re: [mg64935] Fastest method for comparing overlapping times in random time series*From*: "Carl K. Woll" <carlw at wolfram.com>*Date*: Fri, 10 Mar 2006 05:14:57 -0500 (EST)*References*: <200603080559.AAA03078@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Prince-Wright, Robert G SEPCO wrote: > I have two lists, list1{ {t1,t1+dt1}, {t2,t2+dt2},..{ti,ti+dti}}, and > list2, each representing 'time(i)' and corresponding 'time(i) + > deltatime(i)'. The time(i) values are determined by an exponential > inter-arrival time model, and the durations are a scaled uniform random > variable. Both lists are ordered on time(i). You can think of list 1 as > representing periods when System 1 is not working, and list 2 as the > periods when System 2 is not working. Example lists are given as Cell > Expressions below together with code to convert to a ticker-tape Plot > (you may need to stretch the graphic to see clearly). The challenge is > to develop a fast method for determining the periods when both Systems > are not working, i.e. to create a list corresponding to the start and > finish times of the overlaps. > > Thus far I have only managed to use a Do loop which is very slow for long lists! > > Bob > [snip] > > Robert Prince-Wright > Risk Management Engineer, EP Americas > Shell Exploration & Production Company > Woodcreek, 200 North Dairy Ashford > Houston, TX 77079, USA > > Tel: +1 281 544 3016 > Fax: +1 281 544 2238 > Shell MeetMe Tel. +1 713 423 0600, Participant Code 62709127 > Email: robert.prince-wright at shell.com > Internet: http://www.shell.com > Use Interval objects: In[23]:= i1=Interval@@list1; i2=Interval@@list2; IntervalIntersection[i1,i2] Out[25]= Interval[{0,0},{7.97854,7.97952},{23.9643,24.0535},{31.0982,31.1416},{32.5135, 32.547}] will give you an Interval object with the overlaps. Carl Woll Wolfram Research

**References**:**Fastest method for comparing overlapping times in random time series***From:*"Prince-Wright, Robert G SEPCO" <robert.prince-wright@shell.com>