Jsoftware
High-Performance Development Platform

fast 1-d linear interpolation

View: New views
20 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

fast 1-d linear interpolation

by sean-108 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'd be interested to see if anyone can suggest improvements to the
following code snippets...

I have been doing some calculations recently involving interpolations on
vectors containing several thousand points.  A simple equivalent of the
problem might involve a vector of X values and a corresponding vector of
Y values: for example,

X =: i. 10000
Y =: X^1.1

I then need to scale the x-values by a small amount and interpolate on
some of these interior points XI.  For example,

XI =: 1.1 * i.8000

So I want to find YI that corresponds to linearly interpolated values of
Y evaluated at XI.

I initially used the algorithm posted to this forum previously by R.E.
Boss, and shown below.

interp1=: 4 : 0  NB. From R.E. Boss,
NB. eg XI interp1 X;Y, where XI are the interpolation points
NB. and X and Y are the original data
slopes=. %~/2-~/\&>y
index=. <1 i:~"1 x>:/__,}._,~}:>{.y
't0 t1 t2'=. index {&> slopes;y
t2+t0*x-t1
)

This is very elegant and accounts for extrapolation.  But on the example
matrix here it takes about 5 seconds to run on my computer.  I would
like it to be faster than this.  I will have to call this routine
several times as it's part of a least-squares fitting routine.

I can arrange XI before interpolating so that it is always within the
limits of X, removing the need to cater for extrapolation.  Also, both X
and XI have monotonically increasing values.  Looking at interp1, most
of the time is spent evaluating the x >:/ part of the code.

To speed it up, I noted that once the index of X immediately lower than
the current XI had been determined, searches of X for subsequent
elements of XI don't need to keep checking the elements of X  prior to
that index.  Using loops, I wrote the following slight modification of
the code to avoid these extra checks:

indices =: 4 : 0
list =. 0
 for_XI. x do.
  for_X. ({:list)}.y do.
    if. (X > XI) do. list=.list,(({: list) + <: X_index) break. end.
  end.
 end.
 < }. list
)

interp2 =: 4 : 0
  slopes=. %~/2-~/\&>y
  't0 t1 t2'=: (x indices 0{ > y) {&> slopes;y
  t2+t0*x-t1
)

This works OK for my data, and the execution time (around 0.3 seconds on
my computer for the data above) is acceptable for my needs.

So is there a way of doing something similar to the indices verb that
does not involve using for. loops?  Or, indeed, is there a neater way of
doing this using for. loops?  I'd like to see how others might tackle this.

Thanks,

Sean O'Byrne
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Re: fast 1-d linear interpolation

by Raul Miller-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I would be tempted to use I. to find my indices.

(Also, since your data should have matching shapes,
I would be tempted to not use boxes.  But boxing
should not be relevant to your performance.)

--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

RE: fast 1-d linear interpolation

by Henry Rich :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The line

index=. <1 i:~"1 x>:/__,}._,~}:>{.y

creates a 2-dimensional array, shape (#y),(#y) which
no doubt is what is slow.

What you want is something like

index =. ({.y) I.&:> x

but not exactly, as you can see by experimenting.  I think if
you change the final computation you can make the faster
index computation serve.

Henry Rich

> -----Original Message-----
> From: programming-bounces@...
> [mailto:programming-bounces@...] On Behalf Of sean
> Sent: Thursday, June 12, 2008 7:34 AM
> To: Programming forum
> Subject: [Jprogramming] fast 1-d linear interpolation
>
> I'd be interested to see if anyone can suggest improvements to the
> following code snippets...
>
> I have been doing some calculations recently involving
> interpolations on
> vectors containing several thousand points.  A simple
> equivalent of the
> problem might involve a vector of X values and a
> corresponding vector of
> Y values: for example,
>
> X =: i. 10000
> Y =: X^1.1
>
> I then need to scale the x-values by a small amount and interpolate on
> some of these interior points XI.  For example,
>
> XI =: 1.1 * i.8000
>
> So I want to find YI that corresponds to linearly
> interpolated values of
> Y evaluated at XI.
>
> I initially used the algorithm posted to this forum previously by R.E.
> Boss, and shown below.
>
> interp1=: 4 : 0  NB. From R.E. Boss,
> NB. eg XI interp1 X;Y, where XI are the interpolation points
> NB. and X and Y are the original data
> slopes=. %~/2-~/\&>y
> index=. <1 i:~"1 x>:/__,}._,~}:>{.y
> 't0 t1 t2'=. index {&> slopes;y
> t2+t0*x-t1
> )
>
> This is very elegant and accounts for extrapolation.  But on
> the example
> matrix here it takes about 5 seconds to run on my computer.  I would
> like it to be faster than this.  I will have to call this routine
> several times as it's part of a least-squares fitting routine.
>
> I can arrange XI before interpolating so that it is always within the
> limits of X, removing the need to cater for extrapolation.  
> Also, both X
> and XI have monotonically increasing values.  Looking at interp1, most
> of the time is spent evaluating the x >:/ part of the code.
>
> To speed it up, I noted that once the index of X immediately
> lower than
> the current XI had been determined, searches of X for subsequent
> elements of XI don't need to keep checking the elements of X  prior to
> that index.  Using loops, I wrote the following slight modification of
> the code to avoid these extra checks:
>
> indices =: 4 : 0
> list =. 0
>  for_XI. x do.
>   for_X. ({:list)}.y do.
>     if. (X > XI) do. list=.list,(({: list) + <: X_index) break. end.
>   end.
>  end.
>  < }. list
> )
>
> interp2 =: 4 : 0
>   slopes=. %~/2-~/\&>y
>   't0 t1 t2'=: (x indices 0{ > y) {&> slopes;y
>   t2+t0*x-t1
> )
>
> This works OK for my data, and the execution time (around 0.3
> seconds on
> my computer for the data above) is acceptable for my needs.
>
> So is there a way of doing something similar to the indices verb that
> does not involve using for. loops?  Or, indeed, is there a
> neater way of
> doing this using for. loops?  I'd like to see how others
> might tackle this.
>
> Thanks,
>
> Sean O'Byrne
> ----------------------------------------------------------------------
> For information about J forums see
> http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

RE: fast 1-d linear interpolation

by Henry Rich :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here is a verb for resampling.  Tested a little bit.
It uses unboxed right operand because I didn't see that
boxing was necessary & it usually slows things down.

NB. Resampling
NB. y is (x values),:(y values)
NB. x is new x values
NB. Result is new y values
resamp =: 4 : 0
NB. Intervals are numbered by the index of the sample that
NB. ends the interval.  So, interval 0 is before the first sample
NB. and interval {:$y is after the last.  We calculate the
NB. interval number for each x and then, if it is one of those
NB. off-the-end intervals, adjust to the nearest interior interval.
NB. This means we extrapolate out-of-range values using the slope
NB. of the outermost intervals.
ix =. 1 >. (<:{:$y) <. (0{y) I. x
NB. Calculate the slope dy/dx for each interval.  Prepend a
NB. dummy value to account for the fact that the first interval
NB. is actually interval number 1
intslope =. 0 , %~/ 2 -/\"1 y
NB. The value to return is the y at the end of the interval,
NB. adjusted by the distance of the sampling x from the end of the
NB. interval
(ix { 1 { y) + (ix { intslope) * (ix { 0 { y) -~ x
)

Henry Rich

> -----Original Message-----
> From: programming-bounces@...
> [mailto:programming-bounces@...] On Behalf Of sean
> Sent: Thursday, June 12, 2008 7:34 AM
> To: Programming forum
> Subject: [Jprogramming] fast 1-d linear interpolation
>
> I'd be interested to see if anyone can suggest improvements to the
> following code snippets...
>
> I have been doing some calculations recently involving
> interpolations on
> vectors containing several thousand points.  A simple
> equivalent of the
> problem might involve a vector of X values and a
> corresponding vector of
> Y values: for example,
>
> X =: i. 10000
> Y =: X^1.1
>
> I then need to scale the x-values by a small amount and interpolate on
> some of these interior points XI.  For example,
>
> XI =: 1.1 * i.8000
>
> So I want to find YI that corresponds to linearly
> interpolated values of
> Y evaluated at XI.
>
> I initially used the algorithm posted to this forum previously by R.E.
> Boss, and shown below.
>
> interp1=: 4 : 0  NB. From R.E. Boss,
> NB. eg XI interp1 X;Y, where XI are the interpolation points
> NB. and X and Y are the original data
> slopes=. %~/2-~/\&>y
> index=. <1 i:~"1 x>:/__,}._,~}:>{.y
> 't0 t1 t2'=. index {&> slopes;y
> t2+t0*x-t1
> )
>
> This is very elegant and accounts for extrapolation.  But on
> the example
> matrix here it takes about 5 seconds to run on my computer.  I would
> like it to be faster than this.  I will have to call this routine
> several times as it's part of a least-squares fitting routine.
>
> I can arrange XI before interpolating so that it is always within the
> limits of X, removing the need to cater for extrapolation.  
> Also, both X
> and XI have monotonically increasing values.  Looking at interp1, most
> of the time is spent evaluating the x >:/ part of the code.
>
> To speed it up, I noted that once the index of X immediately
> lower than
> the current XI had been determined, searches of X for subsequent
> elements of XI don't need to keep checking the elements of X  prior to
> that index.  Using loops, I wrote the following slight modification of
> the code to avoid these extra checks:
>
> indices =: 4 : 0
> list =. 0
>  for_XI. x do.
>   for_X. ({:list)}.y do.
>     if. (X > XI) do. list=.list,(({: list) + <: X_index) break. end.
>   end.
>  end.
>  < }. list
> )
>
> interp2 =: 4 : 0
>   slopes=. %~/2-~/\&>y
>   't0 t1 t2'=: (x indices 0{ > y) {&> slopes;y
>   t2+t0*x-t1
> )
>
> This works OK for my data, and the execution time (around 0.3
> seconds on
> my computer for the data above) is acceptable for my needs.
>
> So is there a way of doing something similar to the indices verb that
> does not involve using for. loops?  Or, indeed, is there a
> neater way of
> doing this using for. loops?  I'd like to see how others
> might tackle this.
>
> Thanks,
>
> Sean O'Byrne
> ----------------------------------------------------------------------
> For information about J forums see
> http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

RE: fast 1-d linear interpolation

by Henry Rich :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a slightly better version: fewer copies of the data, and
the structure of the code will allow replacing the linear
interpolation with a cubic spline or the like as needed:

NB. Resampling
NB. y is (x values),:(y values)
NB. x is new x values
NB. Result is new y values
resamp =: 4 : 0
NB. Intervals are numbered by the index of the sample that
NB. ends the interval.  So, interval 0 is before the first sample
NB. and interval {:$y is after the last.  We calculate the
NB. interval number for each x and then, if it is one of those
NB. off-the-end intervals, adjust to the nearest interior interval.
NB. This means we extrapolate out-of-range values using the slope
NB. of the outermost intervals.
ix =. 1 >. (<:{:$y) <. (0{y) I. x
NB. Calculate the interpolating polynomial for each interval.
NB. Here we use linear interpolation, so the polynomial is (y value),(dy/dx)
NB. Create a polynomial for the first interval (off the beginning),
NB. using the slope of the first internal interval
intpoly =. (1 { y) ,. (,~ {.)   %~/ 2 -/\"1 y
NB. The value to return is the interpolating polynomial, evaluated
NB. given the distance between the desired value and the origin point
NB. (i. e. right endpoint) of the interval
(ix { intpoly) p. ((<0;ix) { y) -~ x
)
 

> -----Original Message-----
> From: programming-bounces@...
> [mailto:programming-bounces@...] On Behalf Of Henry Rich
> Sent: Sunday, June 15, 2008 5:12 PM
> To: 'Programming forum'
> Subject: RE: [Jprogramming] fast 1-d linear interpolation
>
> Here is a verb for resampling.  Tested a little bit.
> It uses unboxed right operand because I didn't see that
> boxing was necessary & it usually slows things down.
>
> NB. Resampling
> NB. y is (x values),:(y values)
> NB. x is new x values
> NB. Result is new y values
> resamp =: 4 : 0
> NB. Intervals are numbered by the index of the sample that
> NB. ends the interval.  So, interval 0 is before the first sample
> NB. and interval {:$y is after the last.  We calculate the
> NB. interval number for each x and then, if it is one of those
> NB. off-the-end intervals, adjust to the nearest interior interval.
> NB. This means we extrapolate out-of-range values using the slope
> NB. of the outermost intervals.
> ix =. 1 >. (<:{:$y) <. (0{y) I. x
> NB. Calculate the slope dy/dx for each interval.  Prepend a
> NB. dummy value to account for the fact that the first interval
> NB. is actually interval number 1
> intslope =. 0 , %~/ 2 -/\"1 y
> NB. The value to return is the y at the end of the interval,
> NB. adjusted by the distance of the sampling x from the end of the
> NB. interval
> (ix { 1 { y) + (ix { intslope) * (ix { 0 { y) -~ x
> )
>
> Henry Rich
>
> > -----Original Message-----
> > From: programming-bounces@...
> > [mailto:programming-bounces@...] On Behalf Of sean
> > Sent: Thursday, June 12, 2008 7:34 AM
> > To: Programming forum
> > Subject: [Jprogramming] fast 1-d linear interpolation
> >
> > I'd be interested to see if anyone can suggest improvements to the
> > following code snippets...
> >
> > I have been doing some calculations recently involving
> > interpolations on
> > vectors containing several thousand points.  A simple
> > equivalent of the
> > problem might involve a vector of X values and a
> > corresponding vector of
> > Y values: for example,
> >
> > X =: i. 10000
> > Y =: X^1.1
> >
> > I then need to scale the x-values by a small amount and
> interpolate on
> > some of these interior points XI.  For example,
> >
> > XI =: 1.1 * i.8000
> >
> > So I want to find YI that corresponds to linearly
> > interpolated values of
> > Y evaluated at XI.
> >
> > I initially used the algorithm posted to this forum
> previously by R.E.
> > Boss, and shown below.
> >
> > interp1=: 4 : 0  NB. From R.E. Boss,
> > NB. eg XI interp1 X;Y, where XI are the interpolation points
> > NB. and X and Y are the original data
> > slopes=. %~/2-~/\&>y
> > index=. <1 i:~"1 x>:/__,}._,~}:>{.y
> > 't0 t1 t2'=. index {&> slopes;y
> > t2+t0*x-t1
> > )
> >
> > This is very elegant and accounts for extrapolation.  But on
> > the example
> > matrix here it takes about 5 seconds to run on my computer.  I would
> > like it to be faster than this.  I will have to call this routine
> > several times as it's part of a least-squares fitting routine.
> >
> > I can arrange XI before interpolating so that it is always
> within the
> > limits of X, removing the need to cater for extrapolation.  
> > Also, both X
> > and XI have monotonically increasing values.  Looking at
> interp1, most
> > of the time is spent evaluating the x >:/ part of the code.
> >
> > To speed it up, I noted that once the index of X immediately
> > lower than
> > the current XI had been determined, searches of X for subsequent
> > elements of XI don't need to keep checking the elements of
> X  prior to
> > that index.  Using loops, I wrote the following slight
> modification of
> > the code to avoid these extra checks:
> >
> > indices =: 4 : 0
> > list =. 0
> >  for_XI. x do.
> >   for_X. ({:list)}.y do.
> >     if. (X > XI) do. list=.list,(({: list) + <: X_index) break. end.
> >   end.
> >  end.
> >  < }. list
> > )
> >
> > interp2 =: 4 : 0
> >   slopes=. %~/2-~/\&>y
> >   't0 t1 t2'=: (x indices 0{ > y) {&> slopes;y
> >   t2+t0*x-t1
> > )
> >
> > This works OK for my data, and the execution time (around 0.3
> > seconds on
> > my computer for the data above) is acceptable for my needs.
> >
> > So is there a way of doing something similar to the indices
> verb that
> > does not involve using for. loops?  Or, indeed, is there a
> > neater way of
> > doing this using for. loops?  I'd like to see how others
> > might tackle this.
> >
> > Thanks,
> >
> > Sean O'Byrne
> >
> ----------------------------------------------------------------------
> > For information about J forums see
> > http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see
> http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Re: fast 1-d linear interpolation

by J. Patrick Harrington :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

   This is what I've used for linear interpolation in large arrays. I
tried it on the example below and it took ~0.002 sec on my machine.
---------------------------------------------------------------------
NB. linear interpolation: (x;y) lintrp x0 --> y(x0)
NB. x & y boxed, x0 may be a vector, extrapolate off ends.

lintrp=: 4 : 0
'xx yy'=. x
g0=. (}: yy)% d=. DEL xx
g1=. (}. yy)% d
u=. (g0* }.xx) - g1* }:xx
n=. xx IdX y
(n{u)+ y*n{g1-g0
)

NB. x IdX x0 --> index where x0 fits in x-array, e.g.:
NB.    0   1   2   3   4   5   6  <- x values
NB.    |   |   |   |   |   |   |
NB.  <-- 0 | 1 | 2 | 3 | 4 | 5 --->  IdX values
IdX=: ] I.~ [: }: [: }. [
DEL =: }. - }:
------------------------------------------------------------------------
                                                   Patrick

PS. I've sent this to Sean, but had trouble posting to the newsgroup
     last week as my "From:" name had changed.

On Thu, 12 Jun 2008, sean wrote:

> I'd be interested to see if anyone can suggest improvements to the
> following code snippets...
>
> I have been doing some calculations recently involving interpolations on
> vectors containing several thousand points.  A simple equivalent of the
> problem might involve a vector of X values and a corresponding vector of
> Y values: for example,
>
> X =: i. 10000
> Y =: X^1.1
>
> I then need to scale the x-values by a small amount and interpolate on
> some of these interior points XI.  For example,
>
> XI =: 1.1 * i.8000
>
> So I want to find YI that corresponds to linearly interpolated values of
> Y evaluated at XI.
>
> I initially used the algorithm posted to this forum previously by R.E.
> Boss, and shown below.
>
> interp1=: 4 : 0  NB. From R.E. Boss,
> NB. eg XI interp1 X;Y, where XI are the interpolation points
> NB. and X and Y are the original data
> slopes=. %~/2-~/\&>y
> index=. <1 i:~"1 x>:/__,}._,~}:>{.y
> 't0 t1 t2'=. index {&> slopes;y
> t2+t0*x-t1
> )
>
> This is very elegant and accounts for extrapolation.  But on the example
> matrix here it takes about 5 seconds to run on my computer.  I would
> like it to be faster than this.  I will have to call this routine
> several times as it's part of a least-squares fitting routine.
>
> I can arrange XI before interpolating so that it is always within the
> limits of X, removing the need to cater for extrapolation.  Also, both X
> and XI have monotonically increasing values.  Looking at interp1, most
> of the time is spent evaluating the x >:/ part of the code.
>
> To speed it up, I noted that once the index of X immediately lower than
> the current XI had been determined, searches of X for subsequent
> elements of XI don't need to keep checking the elements of X  prior to
> that index.  Using loops, I wrote the following slight modification of
> the code to avoid these extra checks:
>
> indices =: 4 : 0
> list =. 0
> for_XI. x do.
> for_X. ({:list)}.y do.
>   if. (X > XI) do. list=.list,(({: list) + <: X_index) break. end.
> end.
> end.
> < }. list
> )
>
> interp2 =: 4 : 0
> slopes=. %~/2-~/\&>y
> 't0 t1 t2'=: (x indices 0{ > y) {&> slopes;y
> t2+t0*x-t1
> )
>
> This works OK for my data, and the execution time (around 0.3 seconds on
> my computer for the data above) is acceptable for my needs.
>
> So is there a way of doing something similar to the indices verb that
> does not involve using for. loops?  Or, indeed, is there a neater way of
> doing this using for. loops?  I'd like to see how others might tackle this.
>
> Thanks,
>
> Sean O'Byrne
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Re: fast 1-d linear interpolation

by J. Patrick Harrington :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

   For some reason my mail program doesn't like the isolated ")"
that ends lintrp - it should of course be

--->(n{u)+ y*n{g1-g0
--->)

On Mon, 16 Jun 2008, J. Patrick Harrington wrote:

>  This is what I've used for linear interpolation in large arrays. I
> tried it on the example below and it took ~0.002 sec on my machine.
> ---------------------------------------------------------------------
> NB. linear interpolation: (x;y) lintrp x0 --> y(x0)
> NB. x & y boxed, x0 may be a vector, extrapolate off ends.
>
> lintrp=: 4 : 0
> 'xx yy'=. x
> g0=. (}: yy)% d=. DEL xx
> g1=. (}. yy)% d
> u=. (g0* }.xx) - g1* }:xx
> n=. xx IdX y
> (n{u)+ y*n{g1-g0 )
>
> NB. x IdX x0 --> index where x0 fits in x-array, e.g.:
> NB.    0   1   2   3   4   5   6  <- x values
> NB.    |   |   |   |   |   |   |
> NB.  <-- 0 | 1 | 2 | 3 | 4 | 5 --->  IdX values
> IdX=: ] I.~ [: }: [: }. [
> DEL =: }. - }:
> ------------------------------------------------------------------------
>                                                  Patrick
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Re: fast 1-d linear interpolation

by sean-108 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks very much Patrick, Henry and Raul for your suggestions.

I did not read far enough down in the dictionary to see I. when looking
to solve this problem. I've learned a lot from this simple problem.  On
my machine:

   ts 'YISO =: XI interp3 X;Y'
0.360464 1.37946e6
   ts 'YIJPH =: (X;Y) lintrp XI'
0.007234 887680
   ts 'YIHR =: XI resamp X,:Y'
0.017489 1.54445e6

There is a very small difference (of the order 1e_8, increasing with
index and evenly distributed about zero) between Patrick's very fast and
memory-efficient version's YI values and those of the other three
routines for my example problem.  It may be a rounding error, but I have
not investigated the reason for the discrepancy yet.  plot XI;YISO-YIJPH
shows the difference.

Sean

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

hwndp and Vista Task Manager

by Henry Rich :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Vista...  (for those who helped with the cut/paste problem,
the issue turned out to be that a user-level task is not allowed
to send events to an edministrative task; to have your mouse
send events to a task running as administrator, you have to
start it as administrator; but you can't do that from the
normal start procedure; so you have to create a Scheduled
Task to start your mouse with administrative rights

but that was long ago).  The problem now is that my application,
which is very solid on Windows XP, fails on Windows Vista
in the following sequence:

0.  I press CTRL-ALT-DEL
1.  I get the 'choose your program' screen
2.  (now I'm speculating, but I think my app tries to create a window
  at this point)
3.  I select Task Manager
4.  Task Manager starts
5.  My program blows up with a domain error because it has an
  invalid window handle.


Apparently something failed when the UAC was quizzing me about
what I wanted to do.  Maybe J tried to create a window and wasn't
allowed to?  This has happened to me twice now.

I will instrument the code to find the problem, but I wonder if
anybody here has a clue?  Is window-creation suspended while UAC
has control?  Should J be checking for something, or should I
be?  For example, would I get a return code from wd if I tried to
create/read hwndp for a window that was not created?

Henry Rich

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

J for C Programmers available in book form

by Henry Rich :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

My book _J for C Programmers_ is now available as a bound & printed
book from lulu.com.  The ordering page is

http://www.lulu.com/content/2695144

Think about it: You could buy a decent bottle of wine, drink it, &
head off for a good night's sleep.  But for the same money, you
could buy my book and be put to sleep whenever you want to!


Henry Rich

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Strange segment in wire plot

by Fraser Jackson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Can anyone tell me how to get rid of the red line in the following plot
which is a small segment of a
much larger plot?

      gg =: 0 : 0
      0 850.823 840.919 7804.77 1301.74
850.823       0 55327.9 579.847 147.268
840.919 55327.9       0 557.103 150.447
7804.77 579.847 557.103       0 3421.03
1301.74 147.268 150.447 3421.03       0
)
      gg =: ". ] ;._2 gg
      'wire' plot gg

Fraser

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Re: Strange segment in wire plot

by Devon McCormick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Maybe this segment is telling you something about your data?  E.g.
   'surface' plot gg
shows a (red) face between two peaks.

On 6/22/08, Fraser Jackson <fraser.jackson@...> wrote:

>
> Can anyone tell me how to get rid of the red line in the following plot
> which is a small segment of a
> much larger plot?
>
>     gg =: 0 : 0
>     0 850.823 840.919 7804.77 1301.74
> 850.823       0 55327.9 579.847 147.268
> 840.919 55327.9       0 557.103 150.447
> 7804.77 579.847 557.103       0 3421.03
> 1301.74 147.268 150.447 3421.03       0
> )
>     gg =: ". ] ;._2 gg
>     'wire' plot gg
>
> Fraser
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

RE: J for C Programmers available in book form

by Dan Bron :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I bought a copy too.  I'm interested to know who those people are on the cover, and why they're there.

-Dan

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jgeneral] J for C Programmers available in book form

by Chris Burke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Henry Rich wrote:
> My book _J for C Programmers_ is now available as a bound & printed
> book from lulu.com.  The ordering page is
>
> http://www.lulu.com/content/2695144
>
> Think about it: You could buy a decent bottle of wine, drink it, &
> head off for a good night's sleep.  But for the same money, you
> could buy my book and be put to sleep whenever you want to!

Please post comments on this in the general forum, thanks. No need to
cross-post.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Re: Strange segment in wire plot

by Raul Miller-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 6/22/08, Devon McCormick <devonmcc@...> wrote:
> Maybe this segment is telling you something about your data?  E.g.
>   'surface' plot gg
> shows a (red) face between two peaks.

This also has a red face:
   'wire'plot gg+(0=gg)*>./,gg

Anyways, I have no idea how plot picks its colors.

--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Re: Strange segment in wire plot

by neitzel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Fraser Jackson wrote:
>      gg =: 0 : 0
>      0 850.823 840.919 7804.77 1301.74
>850.823       0 55327.9 579.847 147.268
>...
>)
>      gg =: ". ] ;._2 gg

       gg =:    ".;._2 gg

is a bit more straight forward.

                                                        Martin
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Working with J

by Kip Murray :: Rate this Message: