So here are two verbs that do find the start for the match of a and b in c
5 and 20



fa=: 3 : 0
indexc=:y
matchac=:lengtha{.indexc}.codc
timediff=:matchac - coda
meantimediff=:{.lengtha%~+/timediff
+/|timediff (0.002 tcmp) ~meantimediff
)

  ($ #: (i. <./)@,) ,>fa each i. lengthc
5

fb=: 3 : 0
indexc=:y
matchbc=:lengthb{.indexc}.codc
timediff=:matchbc - codb
meantimediff=:{.lengthb%~+/timediff
+/|timediff (0.002 tcmp) ~meantimediff
)


  ($ #: (i. <./)@,) ,>fb each i. lengthc
20


2007/3/30, Björn Helgason <[EMAIL PROTECTED]>:

This works quite nicely

Here is an example from test indexc equal 5 seems to be a starting point
for matching a to c matching tolerance 0.002

   coda=:24 60 60 1000 #.a
   codc=:24 60 60 1000 #.c
   lengtha=:$coda

   indexc=:0

   matchac=:lengtha{.indexc}.codc

   timediff=:matchac - coda

   meantimediff=:{.lengtha%~+/timediff

   +/|timediff (0.001 tcmp) ~meantimediff
15

   indexc=:5

   +/|timediff (0.001 tcmp) ~meantimediff
1

   +/|timediff (0.002 tcmp) ~meantimediff
0

   indexc=:10

      +/|timediff (0.001 tcmp) ~meantimediff
15


2007/3/29, Oleg Kobchenko <[EMAIL PROTECTED]>:
>
> Sorry, wrong scale direction, with increase
> of radius is should become more tolerant (returning 0).
>
> Correct is
>
>    tcmp=: 1 : '- ([EMAIL PROTECTED] * >&|) m*>.'
>
>    1134000 (0.001 tcmp)  1138000
> _1
>    1134000 (0.001 tcmp)~  1138000
> 1
>    1134000 (0.01 tcmp)  1138000
> 0
>
>    2 2.01 2.02 2.03 (0.01 tcmp) 2
> 0 0 0 1
>    2 2.01 2.02 2.03 (0.01 tcmp)&- 2
> 0 0 0 _1
>    _1 1 (0.01 tcmp) 1 _1
> _1 1
>
>
>    2 2.001 2.01 2.1 2.5 (0.0001 tcmp) 2
> 0 1 1 1 1
>    2 2.001 2.01 2.1 2.5 (0.001 tcmp) 2
> 0 0 1 1 1
>    2 2.001 2.01 2.1 2.5 (0.01 tcmp) 2
> 0 0 0 1 1
>    2 2.001 2.01 2.1 2.5 (0.1 tcmp) 2
> 0 0 0 0 1
>    2 2.001 2.01 2.1 2.5 (0.5 tcmp) 2
> 0 0 0 0 0
>
>
> --- Bj�rn Helgason <[EMAIL PROTECTED]> wrote:
>
> > Right to the point as usual!
> >
> > 2007/3/29, Oleg Kobchenko < [EMAIL PROTECTED]>:
> > >
> > > Maybe you need to convert the timestamps to
> > > integers and use a scaled tolerant comparison:
> > >
> > >    tcmp=: 1 : '(m*>.) (>&| * [EMAIL PROTECTED]) -'
> > >    1134000 (0.01 tcmp)  1138000
> > > _1
> > >    1134000 (0.001 tcmp)  1138000
> > > 0
> > >    1134000 (0.01 tcmp)~  1138000
> > > 1
> > >
> > > This is by extended definition of ''tolerance''.
> > >
> > > http://www.google.com/search?q=tolerance&sitesearch=jsoftware.com
> > >
> > >
> > >
> > > --- Bj�rn Helgason <[EMAIL PROTECTED]> wrote:
> > >
> > > > Lets say that the problem is to do a fuzzy match
> > > > Not exact match.
> > > > As you see the time difference is sometimes 18 56, 18 55, 18 57 so
> a
> > > good
> > > > match is something like 18 56 +/- 1  or 2 seconds
> > > > It would not be any problem if the difference is always exactly 18
> 56
> > > > The problem is also finding what the time difference is and in
> what
> > > > direction.
> > > > Time difference by some measurements outside the few second span
> would
> > > not
> > > > be good.
> > > >
> > > > So getting a 0/1 answer would rather be something like an interval
> of a
> > > few
> > > > seconds for the timedifferences in each case
> > > >
> > > > This problem is fairly trivial to do manually.
> > > >
> > > > Finding the probe by looking at the image was also trivial
> manually.
> > > > Seeing if the probe was there and if it was in the center or in
> the
> > > > periphery.
> > > > Doing it by a program seemed to me like an impossibility a month
> ago.
> > > > That part is the easy part now.
> > > >
> > > > Doing this fuzzy matching is probably easy as well even if it is
> not
> > > crystal
> > > > clear to me right now.
> > > > The differences in time are probably triggered by that the probe
> is
> > > > triggered by receiving exposure and it seems to vary a second or
> two.
> > > > Also the clock in each equipment is not in sync.
> > > >
> > > > The correct match could be within quite a span if the number is
> coded
> > > >
> > > >      24 60 60 1000 #.0 18 54 0
> > > > 1134000
> > > >     24 60 60 1000 #.0 18 58 0
> > > > 1138000
> > > >
> > > > 2007/3/29, Devon McCormick < [EMAIL PROTECTED]>:
> > > > >
> > > > > So, taking your guess here of the time offset of 18 minutes, 56
> > > seconds= 0
> > > > > 18 56 0, I can
> > > > > adjust c:
> > > > >
> > > > >    3{.adjc=. 24 60 60 1000 #: (24 60 60 1000 #.c)-24 60 60 1000
> #. 0
> > > 18 56
> > > > > 0
> > > > > 10 57 51 450
> > > > > 10 57 59 150
> > > > > 10 58 6 950
> > > > >
> > > > > and come up with a boolean to interpolate it into a,b:
> > > > >
> > > > >    (#adjc)>gv=. /: adjc,a,b
> > > > > 1 1 1 1 1 0 1 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
> 1 0 1
> > > 1 0
> > > > > 0
> > > > > 1 0 1 1 0 0 1 0 1 0 1 0 1 1 0 0 1 0 1 0 1 1 0 1 0 0 1
> > > > >
> > > > > where the 1s mark successive elements of c and the 0s mark
> successive
> > > > > elements of a,b.  Is this any help?
> > > > >
> > > > >
> > > > > On 3/29/07, Bj�rn Helgason < [EMAIL PROTECTED]> wrote:
> > > > > >
> > > > > > All of c come from a CT or similar equipment.
> > > > > > a and b come from a instrument that are put into the CT.
> > > > > >
> > > > > > The CT gives exposure and in c come the times - and lots of
> other
> > > > > > information when the exposure is made.
> > > > > >
> > > > > > a and b come from the instrument - a probe in a phantom -
> measure
> > > doses
> > > > > > and
> > > > > > such and also register time.
> > > > > >
> > > > > > I have been making program to find the place where the probe
> was on
> > > the
> > > > > > image.
> > > > > >
> > > > > > I have gathered the information from different files I get.
> > > > > >
> > > > > > I may not be getting the correct files, files may be missing.
> > > > > >
> > > > > > I know a,b and c came from the same session.
> > > > > >
> > > > > > The person did some exposures before the probe was connected
> so some
> > > > > > values
> > > > > > are missing.
> > > > > >
> > > > > > It is quite obvious that the clock in the probe (a and b) and
> in the
> > > CT
> > > > > > (c)
> > > > > > are not in sync.
> > > > > > The time difference is ca 18 minutes and 56 seconds as you can
> see
> > > doing
> > > > > > the
> > > > > > calculations.
> > > > > >
> > > > > > I have a gap at the beginning introducing d to fill the gap.
> > > > > > The gap could have been in the middle.
> > > > > > I have no way of knowing in advance.
> > > > > >
> > > > > > I am trying to make a reasonable guess which times fit so I
> can
> > > match
> > > > > the
> > > > > > exposure doses gathered from the probe (a and b) and not
> having to
> > > do it
> > > > > > manually.
> > > > > >
> > > > > > The time difference is not exactly 18 minutes and 56 seconds
> between
> > > all
> > > > > > corresponding lines in c and the lines in a and b. I do not
> know in
> > > > > > advance
> > > > > > if I do have a time difference and I do not know which way the
>
> > > > > difference
> > > > > > is
> > > > > > going to be.
> > > > > >
> > > > > > It is fair to assume all the times in c to be sorted.
> > > > > > It is also fair to assume the the individual files a and b are
>
> > > sorted.
> > > > > >
> > > > > > I have to find where lines in a matches lines in c
> > > > > > I have to find where lines in b matches lines in c
> > > > > >
> > > > > > The time difference in all cases should be roughly the same.
> > > > > >
> > > > > > I guess if I get a file - lets call it e - I would have to try
> to be
> > > > > able
> > > > > > to
> > > > > > make an educated guess that I could not find any match and it
> would
> > > be
> > > > > > from
> > > > > > some other test.
> > > > > >
> > > > > > Hope that explains the task at hand fairly well.
> > > > > >
> > > > > > Up to now I have done this part manually but would like to be
> able
> > > to
> > > > > see
> > > > > > if
> > > > > > I could get this to work.
> > > > > > I have never tried to match something like this with a program
> > > before.
> > > > > > Most of the time there is an exact match or there is not.
> > > > > > Not such a fuzzy match of matching roughly.
> > > > > >
> > > > > > Obviously I have to match the dates as well and both the
> formats of
> > > the
> > > > > > date
> > > > > > and the time were different.
> > > > > > I also added 000 in both a and b
> > > > > > If I am not lucky the test person could be sending in files
> from
> > > > > different
> > > > > > tests.
> > > > > > I am working on what requirements the test persons are
> supposed to
> > > have.
> > > > > > Try to exclude complete morons somehow politely.
> > > > > >
> > > > > > 2007/3/29, Devon McCormick <[EMAIL PROTECTED]>:
> > > > > > >
> > > > > > > Gosi - I don't understand what you're trying to do here.
> > > > > > > Are these timestamps that need to be matched?  If so, it
> looks
> > > like
> > > > > > > all of "c" comes after everything in "a" and "b".
> > > > > > >
> > > > > > >    gv=. /:c,a,b
> > > > > > >    gv<#c
> > > > > > > 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 1 1 1
> > > 1 1
> > > > > 1
> > > > > > 1
> > > > > > > 1
> > > > > > > 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
> > > > > > >
> > > > > > > Also, is there any reason to complicate the problem by
> having a
> > > > > separate
> > > > > > > "a"
> > > > > > > and "b"?
> > > > > > > Aren't you dealing with ab=. a,b versus c?
> > > > > > >
> > > > > > > Maybe I need either more context or a simpler version of
> this.
> > > > > > >
> > > > > > > On 3/29/07, Bj�rn Helgason <[EMAIL PROTECTED]> wrote:
> > > > > > > >
> > > > > > > > Does anyone have a good way of matching times?
> > > > > > > >
> > > > > > > > Here I have an example they happen to be somewhat in
> order.
> > > > > > > > c contains 35 lines that need to be matched with a and b.
> > > > > > > > There is an excess of 5 lines in c compared to a+b so d
> contains
> > > 5
> > > > > > > > dummies.
> > > > > > > >
> > > > > > > > The times need not be sorted like this and they may be
> missing
> > > in
> > > > > > either
> > > > > > > > direction.
> > > > > > > >
> > > > > > > > The task is to get a best match which gives the least time
>
> > > > > difference
> > > > > > > and
> > > > > > > > get the indexes for c that give the best match for a+b
> > > > > > > >
> > > > > > > > There are a lot of fields in each line but only connection
>
> > > between
> > > > > > them
> > > > > > > is
> > > > > > > > the time field.
> > > > > > > > In this example the time difference between the equipment
> is
> > > roughly
> > > > > > 19
> > > > > > > > minutes
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > NB. -----------------head
> > > > > > > >
> > > > > > > > a=:".;._2 (0 : 0)
> > > > > > > > 11 00 29 000
> > > > > > > > 11 00 38 000
> > > > > > > > 11 00 44 000
> > > > > > > > 11 00 52 000
> > > > > > > > 11 01 00 000
> > > > > > > > 11 03 20 000
> > > > > > > > 11 03 28 000
> > > > > > > > 11 03 35 000
> > > > > > > > 11 03 43 000
> > > > > > > > 11 03 51 000
> > > > > > > > 11 05 09 000
> > > > > > > > 11 05 17 000
> > > > > > > > 11 05 25 000
> > > > > > > > 11 05 32 000
> > > > > > > > 11 05 40 000
> > > > > > > > )
> > > > > > > >
> > > > > > > > NB. -------------------- abdomen
> > > > > > > >
> > > > > > > > b=:".;._2 (0 : 0)
> > > > > > > > 11 11 04 000
> > > > > > > > 11 11 11 000
> > > > > > > > 11 11 19 000
> > > > > > > > 11 11 27 000
> > > > > > > > 11 11 34 000
> > > > > > > > 11 12 46 000
> > > > > > > > 11 12 54 000
> > > > > > > > 11 13 02 000
> > > > > > > > 11 13 10 000
> > > > > > > > 11 13 17 000
> > > > > > > > 11 14 36 000
> > > > > > > > 11 14 44 000
> > > > > > > > 11 14 52 000
> > > > > > > > 11 15 00 000
> > > > > > > > 11 15 07 000
> > > > > > > > )
> > > > > > > >
> > > > > > > > NB. ----------------- dcm
> > > > > > > >
> > > > > > > > c=:".;._2 (0 : 0)
> > > > > > > > 11 16 47 450
> > > > > > > > 11 16 55 150
> > > > > > > > 11 17 02 950
> > > > > > > > 11 17 10 600
> > > > > > > > 11 17 18 300
> > > > > > > > 11 19 25 350
> > > > > > > > 11 19 33 200
> > > > > > > > 11 19 41 000
> > > > > > > > 11 19 48 700
> > > > > > > > 11 19 56 450
> > > > > > > > 11 22 16 250
> > > > > > > > 11 22 24 050
> > > > > > > > 11 22 31 750
> > > > > > > > 11 22 39 500
> > > > > > > > 11 22 47 200
> > > > > > > > 11 24 05 650
> > > > > > > > 11 24 13 450
> > > > > > > > 11 24 21 150
> > > > > > > > 11 24 28 850
> > > > > > > > 11 24 36 600
> > > > > > > > 11 29 59 550
> > > > > > > > 11 30 07 350
> > > > > > > > 11 30 15 050
> > > > > > > > 11 30 22 750
> > > > > > > > 11 30 30 450
> > > > > > > > 11 31 42 600
> > > > > > > > 11 31 50 400
> > > > > > > > 11 31 58 100
> > > > > > > > 11 32 05 850
> > > > > > > > 11 32 13 550
> > > > > > > > 11 33 32 400
> > > > > > > > 11 33 40 200
> > > > > > > > 11 33 47 900
> > > > > > > > 11 33 55 600
> > > > > > > > 11 34 03 300
> > > > > > > > )
> > > > > > > >
> > > > > > > > NB. ------------------ auka
> > > > > > > > d=:".;._2 (0 : 0)
> > > > > > > > 0 0 0 0
> > > > > > > > 0 0 0 0
> > > > > > > > 0 0 0 0
> > > > > > > > 0 0 0 0
> > > > > > > > 0 0 0 0
> > > > > > > > )
> > > > > > > >
> > > > > > > > NB. ------------------- example calculations - the last
> one
> > > gives
> > > > > the
> > > > > > > > correct lines hooked together
> > > > > > > > c-a,b,d
> > > > > > > > 24 60 60 1000 #:((24 60 60 1000 #.c)-24 60 60 1000
> #.a,b,d)
> > > > > > > >
> > > > > > > > c-~a,b,d
> > > > > > > > 24 60 60 1000 #:((24 60 60 1000 #.c)-~24 60 60 1000
> #.a,b,d)
> > > > > > > >
> > > > > > > > c-d,a,b
> > > > > > > > 24 60 60 1000 #:((24 60 60 1000 #.c)-24 60 60 1000
> #.d,a,b)
>
>
>
>
> 
____________________________________________________________________________________
>
> It's here! Your new message!
> Get new email alerts with the free Yahoo! Toolbar.
> http://tools.search.yahoo.com/toolbar/features/mail/
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



--
Björn Helgason, Verkfræðingur
Fugl&Fiskur ehf, Þerneyjarsund 23, Box 127
801 Grímsnes ,t-póst: [EMAIL PROTECTED]
Skype: gosiminn, gsm: +3546985532
Landslags og skrúðgarðagerð, gröfuþjónusta
http://groups.google.com/group/J-Programming


Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans

góður kennari getur stigið á tær án þess að glansinn fari af skónum
          /|_      .-----------------------------------.
         ,'  .\  /  | Með léttri lund verður        |
     ,--'    _,'   | Dagurinn í dag                     |
    /       /       | Enn betri en gærdagurinn  |
   (   -.  |        `-----------------------------------'
   |     ) |        (\_ _/)
  (`-.  '--.)       (='.'=)
   `. )----'        (")_(")




--
Björn Helgason, Verkfræðingur
Fugl&Fiskur ehf, Þerneyjarsund 23, Box 127
801 Grímsnes ,t-póst: [EMAIL PROTECTED]
Skype: gosiminn, gsm: +3546985532
Landslags og skrúðgarðagerð, gröfuþjónusta
http://groups.google.com/group/J-Programming


Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans

góður kennari getur stigið á tær án þess að glansinn fari af skónum
         /|_      .-----------------------------------.
        ,'  .\  /  | Með léttri lund verður        |
    ,--'    _,'   | Dagurinn í dag                     |
   /       /       | Enn betri en gærdagurinn  |
  (   -.  |        `-----------------------------------'
  |     ) |        (\_ _/)
 (`-.  '--.)       (='.'=)
  `. )----'        (")_(")
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to