I'm puzzled! - and embarrassed (again).  I should have
checked for consistency, although I don't understand
the aberrant behaviour.

Our correspondent "J Language" should avoid my solution
pro tem.

Following Devon, with apologies for extra line throws

  open=. 100+?1e2$0 [ close=. 100+?1e2$0

  4{. open(</.@:,:) close NB. check 1st few pairs

+-------+---------------+---------------+--------------+
|100.978|100.368 100.971|100.663 100.047|100.874 100.33|
+-------+---------------+---------------+--------------+

  4 {. open((%//.@:,:)) close NB. check ratios...

100.978 1.00601 0.993881 0.994607

NB. .... these are reciprocals of the required ratios!!!

  %/100.368 100.971  NB. it's ok on an explicit pair...

0.994028

  %~/100.368 100.971 NB. evidently %~/ is done here ...

1.00601

  4 {. open((%~//.@:,:))close NB. check inverse ratios...

100.978 1.00601 0.993881 0.994607

NB. ... these are just the same!!!

Why doesn't " ~ " work here?  Is this a bug or one of
those features I keep missing?

Mike
Devon McCormick wrote:
Out of curiousity, is there any particular reason you want a tacit version?

To my eye, still not comfortable with tacit, Raul's initial solution looks
simplest
and most straightforward.

  ocrsum0=: 4 : '+/(}.x) % }:y'              NB. Sum open[n+1]%close[n] -
explicit (Raul's original)
  ocrsum1=: [:+/[EMAIL PROTECTED](]}:)                  NB. Sum 
open[n+1]%close[n] -
tacit
ocrsum2=: (+/@[EMAIL PROTECTED]:@(%//.@:,:)) NB. Sum open[n+1]%close[n] - tacit using
"oblique"
  100 101 103 104 103 102 (ocrsum0-:ocrsum2) 101 100 104 104 105 103
1
  100 101 103 104 103 102 (ocrsum0-:ocrsum1) 101 100 104 104 105 103
1

Mike Day's solution using "oblique", which is the coolest, works the same
for the
example numbers but otherwise has some unexplained differences:

  open=. 100+?1e2$0 [ close=. 100+?1e2$0
  open (ocrsum0-:ocrsum1) close
1
  open (ocrsum0-:ocrsum2) close
0
  open (ocrsum0,ocrsum2) close
99.05473 98.947048

I also liked Mike's initial approach of combining "open" and "close" into a
single array
as this is more "J-like": it reduces the number of items to keep in synch.

On 6/7/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

Given:

open =: 100 101 103 104 103 102
close =: 101 100 104 104 105 103

Calculating

+/ open % close

is easy, but how about

+/ open(index+1) % close(index)

In other words summation of the ration between today's
closing price and tomorrow's opening price.

Easy to do procedurally, but how to do it with tactic
programming.

Trying to empliment "Historical Open-High-Low-Close
Volitility: Yang-Zhang" algorithm found at:

http://www.sitmo.com/eq/417

Probably just rewriting something somebody else already did
in J, but it is good learning new things.

thanks









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




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

Reply via email to