Ok, I've poked around at this Minority Game stuff a bit more.
This is mostly shooting from the hip, but I've at least figured
out a way to express the program tacitly.
First off, I should note that 0.5 * 1 + * y is better expressed
as 0 < y. There's a vanishingly small chance that the expressions
would differ (when 0=y-0.5), but in those cases the surrounding
expressions would almost always throw domain errors.
Second off, I'm going to disclaim again: I have not studied
the concepts underlying this code. So some of my comments and
or function names might be bogus.
Anyways, here's the modified code:
N=: 4097 NB. number of agents
M=: 5 NB. length of history
S=: 2 NB. strategies per agent
NB. initial figures (roughly Gaussian):
P=: +/ 0.5-? (12, N, S)$0 NB. performance
A=: +/ 0.5-? (12, M+1) $0 NB. time sequence
Note 'Bidding logic'
Unless otherwise indicated, performance numbers
will be the left argument for these verbs, and
time sequence will be the right argument for these
verbs. Increasing time is indicated by increasing
index in the time sequence.
)
NB. strategy look-up table (frozen disorder)
R=:1-2*? ((2^M), N, S)$2
NB. strategy look-up function
NB. time indices are left argument
Sbid=: R {~ [: #. 0 < {
NB. performance function
Pbid=: [ - {:@] * (_2-i.-M) Sbid ]
NB. Next strategy
Snew=: (i. >./)"[EMAIL PROTECTED] {"_1 (_1-i.-M) Sbid ]
NB. Impact on outcome
Bid=: (%:N) %~ +/@Snew
NB. (Bids P;A): next P and corresponding A
Bids=: (Pbid ([ ; ] , Bid) ])&>/
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 1 {:: (Bids ^: (2 ^ 14)) P;A
FYI,
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm