smoother

  42 (]`([ ({.@] , <:@[ $: {:@]) ] (] , -) >:@?@([ >.@%~ -~))@.(1 < [)) 380 
7 1 9 9 1 3 3 1 3 10 4 3 5 4 10 6 11 9 3 5 6 11 4 2 5 14 7 1 8 3 15 5 14 10 11 
2 9 3 33 9 5 96 




----- Original Message -----
From: 'Pascal Jasmin' via Programming <[email protected]>
To: "[email protected]" <[email protected]>
Cc: 
Sent: Friday, May 8, 2015 3:04 PM
Subject: Re: [Jprogramming] Random distribution

Here is a recursive (sorry) approach that makes all possible solutions, but 
somewhat likely to crowd out remaining draws (with lots of 1s followed by a 2).

  
  32 (]`([ ({.@] , <:@[ $: {:@]) ] (] , -) >:@?@-~)@.(1 < [)) 380 
152 132 21 3 23 22 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2





----- Original Message -----
From: Dan Bron <[email protected]>
To: [email protected]
Cc: 
Sent: Friday, May 8, 2015 2:40 PM
Subject: Re: [Jprogramming] Random distribution

Joe Bogner wrote:
>  +/ every ( (([: /:~ [: ? N&#) I. i.) </. #&1) Q

Yes, I. does seem germane to me, but I tried this verb and it seemed to
produce vectors of different lengths at each iteration.  I need the result
to be exactly and always N numbers long, and their sum to be exactly and
always Q .

Marshall wrote:
>  The interpretation of the original problem that I would use is: 
>  V is a vector of nonnegative integers with shape N whose sum is Q.

Thanks Marshall.  The actual specification is 

   V is a vector of POSITIVE integers with shape N whose sum is Q.

That is: there must be exactly N buckets, and no bucket may be empty. All
possible ordered series of buckets must be equally likely.

Pascal wrote:
> Maybe show some valid vectors for small Q?

For example [1], for N=3 and Q=7

    1 1 5
    1 2 4
    1 3 3
    1 4 2
    1 5 1
    2 1 4
    2 2 3
    2 3 2
    2 4 1
    3 1 3
    3 2 2
    3 3 1
    4 1 2
    4 2 1
    5 1 1

A very regular pattern, now that I look at it. If we knew the number ZFNP
of possible 0-free N-partitions an integer Q, then we'd only have to roll
?ZFNP and then figure out some function analogous to #: to break it apart
into its constituents.

REB wrote:
>  V=: Q*(%+/) 2 rnd N ?@# 0

This looks promising.  What's rnd here?

Bob wrote:
>  Probably a converging power conjunction

Ideally, I'm looking for an instantaneous / closed form solution, one which
avoids iteration or recurision, if possible.

-Dan

[1] I created this table by hand, but it looks right.




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

----------------------------------------------------------------------
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