Q=. 100
N=. 20
rr=. N?100*N NB. Or however you want to do this
Q%+/rr
0.00499875
+/rr=. <.0.5+rr*Q%+/rr
99
NB. Fix miss
tot=. +/<.0.5+rr*Q%+/rr
+/rr=. ((rp{rr)+Q-tot) (rp=.?#rr)}rr
100
rr
3 6 3 7 7 4 7 0 10 5 4 1 5 5 8 5 7 3 2 8
On Fri, May 8, 2015 at 11:54 AM, Dan Bron <[email protected]> wrote:
> I have a quantity Q and I want to divide it into a vector V of N
> randomly-sized chunks, such that N=#V and Q=+/V .
>
> Ideas?
>
> -Dan
>
>
>
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
Devon McCormick, CFA
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm