Hi Bob,

This is what I think you want:

vector n : constant input for each data-table
data-table <=> (d;o) <=> (waa, paa, maa,:praa);option : d and/or os
variable input

>From this interpretation I get:

da =: waa, paa, maa,:praa

PB=: 4 : 0 "1
 n=. x
 'd os'=. y
 'w per_mat m pr' =. d
 z=.i.0, #w
 for_o. os do.
   f =. m + pr * ( 4 : 'y*x%+/w*(f%z)*n*1-^-z=.m+f=.pr*y'^:_ 2:) `...@.(<&2) o
   z=.z, n=. 3e4,}:n*^-f
 end.
)


And now you can apply:

   n PB 2$,:da;option
30000 12218.96985 23270.97578 11735.56758 ....
.....
.....
30000 24414.99229 19128.84455 12726.63933 8070.354276 ....

30000 12218.96985 23270.97578 11735.56758 ....
.....
.....
30000 24414.99229 19128.84455 12726.63933 8070.354276 ....


1e3 (identical) planes.

   ts 'n PB 1e3$,:da;option'
1.014249 2131008

The actual PB will be:

PB=: 4 : 0 "1
 n=. x
 'd os'=. y
 'w per_mat m pr' =. d
 z=.i.0, #w
 for_o. os do.
   f =. m + pr * ( 4 : 'y*x%+/w*(f%z)*n*1-^-z=.m+f=.pr*y'^:_ 2:) `...@.(<&2) o
   b=. +/per_mat*w*n*^-spawn_t * f
   r=. (b<breakpoint){ ( ({...@$ )recruit_h),({ ~...@$ ) recruit_l
   z=.z, n=. r,}:n*^-f
 end.
)



For a start, but did I understand you correctly?



Hallo Robert O'Boyle, je schreef op 22-01-10 16:45:
> A resend with the script listed below!
>
>  
>
> Hi all
>
>  
>
> Based on the feedback from my last e-mail to the forum, I put together the
> script below. It illustrates my problem more completely. The input data are
> vectors but in a real application, they would be matrices. For each read of
> a list in data, I sample from a table (s_r) to obtain values of the noun,
> recruit. For illustration, I NBed that line and assigned recruit to 30000.
>
>  
>
> My idea was to have each table be an independent series of calculations from
> the same starting n. Thus, here, the output should be two identical tables.
> You will see that the first table estimates each year's n (each row is a
> year in this example) but then the calculations run over to the second table
> using the n from the last row of the first table rather than the same
> starting row as the first table. I have used looping and counters to get
> around this in earlier versions but there should be a matrix way of doing
> this.
>
>  
>
> Any insight would be greatly appreciated!
>
>  
>
> Thanks
>
>  
>
> Bob
>
>  
>
> NB.       Bootstrap Projection
>
> NB.
>
> NB.=====================================================
>
> NB.
>
> NB.       Input Data
>
> n                                  =:         14965 29010 15811 13526 5595
> 5147 1679 1537 0 0 0 0 0 0 0 0
>
> waa                              =:         0.292 0.533 0.795 1.22 1.741
> 2.408 3.347 3.63 4.515 4.926 5.313 5.63 5.885 6.089 6.249 6.375
>
> paa                               =:         0.38 0.91 0.98 1 1 1 1 1 1 1 1
> 1 1 1 1 1
>
> maa                              =:         0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2
> 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2
>
> praa                  =:         0.02 0.15 0.72 1 1 1 1 1 1 1 1 1 1 1 1 1
>
> recruits             =:         80323 48380 48579 53444 43921 13033 27270
> 30352 28686 32316 33158 35257 38694 28258 29339 31185 29433 39386 31181
> 36047 25265 35505 14965
>
> ssb                               =:         22582 24435 21870 19853 18391
> 19082 10883 7025 9940 8743 9905 12287 15100 18976 20067 20413 22245 22551
> 26130 33835 39051 44786 43951
>
> breakpoint         =:         15000
>
> option               =:         10700 0.21 0.3 0.4 0.25 0.15 0.20 0.25 0.3 
>
> s_r                                =:         recruits,:ssb
>
> recruit_l =:         {.(({:s_r)<           breakpoint)#"1 s_r
>
> recruit_h            =:         {.(({:s_r)>:breakpoint)#"1 s_r
>
> spawn_t                        =:         0.9
>
> data                  =:         (waa, paa, maa,:praa);" 2 0 option
>
> NB.
>
> NB.======================================================
>
> NB. 
>
> NB. Functions
>
> NB.
>
>  
>
> F_QUOTA         =:         4 : 0
>
> y*x%(+/w*(f%z)*n*1-^-z=.m+f=.pr*y)
>
> )
>
>  
>
> PROJECT_BOOT =: 3 : 0
>
> y1                                                         =:         >0{y
>
> y2                                                         =:         >1{y
>
> 'w per_mat m pr'            =:         y1
>
> 'opt'                                          =:         y2
>
> f                                                           =:         >(opt
> <2) { (pr * opt (F_QUOTA ^:_) 2); (pr * opt)
>
> b                                                          =:
> +/per_mat*w*n*^-(m+f)*spawn_t
>
> NB. recruit                                             =:
> (b<breakpoint){((?$ recruit_h){ recruit_h),((?$ recruit_l){ recruit_l) 
>
> recruit                                       =:         30000
>
> n                                                          =:
> recruit,}:n *^-(f+m)
>
> )
>
>  
>
> PROJECT_BOOT"2"1 data,:data
>
>  
>
>  
>
>  
>
>  
>
>  
>
>  
>
>  
>
>  
>
>  
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
>   

-- 
Met vriendelijke groet,
=@@i

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

Reply via email to