The verb "cum" does bucketing using a couple of 
outer products and outer product is an expensive 
way to do bucketing.  Instead:

   cum1=: <: @ (#/.~) @ ([EMAIL PROTECTED]@[ , I.)

   y=: (17000 [EMAIL PROTECTED] 0) + _40+17000 [EMAIL PROTECTED] 80 
   (cum y) -: U cum1 y
1
   ts 'cum y'
0.291171 2.51713e7
   ts 'U cum1 y'
0.00176336 265024

cum1 is not equivalent to cum when there are
data points exactly equal to an interval boundary.
But I think that cum1 gives a better answer in
such cases.



----- Original Message -----
From: Alistair Tucker <[EMAIL PROTECTED]>
Date: Monday, October 9, 2006 2:45 am
Subject: [Jprogramming] Minority Game

> Hi people
> Don't know if any of you have come across the minority game before?
> This is my first J program, and much to my surprise it seems to work!
> I do have a couple of questions though:
> I have used quite a few rank conjunctions " in here, I wonder is 
> that perfectly hunky-dory or does it mean that I have set it up badly?
> Also the central function 'bid' modifies global variable p on each 
> iteration, which doesn't strike me as being very 'functional'.  Is 
> there a better way to deal with this?
> I'm quite liking J!  The best thing is that anyone looking over my 
> shoulder won't have the faintest idea what I'm doing, and I can 
> pretend it's something to do with work :)
> Ali
> 
> N =: 4097                                NB. number of agents
> M =: 5                                    NB. length of history
> S =: 2                                    NB. strategies per agent
> 
> R =: _1 + 2 * ? ((2 ^ M) , N , S) $ 2    NB. strategy look-up 
> tables (frozen disorder)
> p =: +/ _0.5 + ? (12 , N , S) $ 0        NB. initial performance 
> figures (approximately Gaussian)
> A =: +/ _0.5 + ? (12 , M + 1) $ 0        NB. initial time sequence 
> (approximately Gaussians)
> 
> bid =: 3 : 0
> p =: p - ({: y) * (#. 0.5 * 1 + * }: (- >: M) {. y) { R
> b =. (p i. " 1 0 >./ " 1 p) { " 0 1 (#. 0.5 * 1 + * (- M) {. y) { R
> y , (+/ b) % %: N
> )
> 
> L =: (_160 + i. 320) % 4
> U =: (_159 + i. 320) % 4
> cum =: 3 : '+/ (y > " 0 1 L) *. (y < " 0 1 U)'
> 
> load 'plot'
> plot (0.5 * L + U) ; cum (bid ^: (2 ^ 14)) A
> 
> www.see.eclipse.co.uk


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

Reply via email to