Re: encoding a vector



On 2008-01-28, muede73 <muede73@xxxxxx> wrote:
Hi,

i need to encode a integer vector as some integer.

v := [ a_1,...,a_n ] , a_i \in {0,n-1}

There is a condition v holds :

a_1+...+a_n <= n^2/4 (1)

I could do it with a base-n-code, but I am looking
for something more efficient, maybe by exploiting (1).
By efficient I mean, that it should fit in a 64bit word for n <= ~20.
A constraint is, that it has to be incremental updateable.

You should specify more clearly what you mean by incrementally updateable.

Anyway, for n=20, the sum is <= 100, so you can think of the problem
so that you have 100 balls to place in 21 numbered urns (one of
which could be a_0).

If you have b balls to place in u urns, the number of combinations
is {b+u-1 \choose u-1} so here you would have {120 \choose 20}
combinations. You could find ranking and unranking algorithms for
k-subsets of a finite set to map (bijectively) each combination to
an integer. These would not be very easily incrementally updatable,
but they would be a compact representation at least.

Harri H.

.



Relevant Pages

  • Re: chess problem
    ... I'm not sure the urns formula will do it; I think it's a little more ... Now imagine all the cars in a row, ... make it impossible to park the SUV we need to place the s - c empty ... The urns are the c+1 slots between the cars, the balls are the s-c ...
    (sci.math)
  • Re: m balls k urns
    ... >urns shoud be distinguishable. ... There are m indistinguishable balls and k distinguishable ... distinguishable urns, with repetitions allowed. ... throws of 3 dice with 6 sides each there are. ...
    (sci.logic)
  • Estimating correlations between groups using binomial sampling
    ... Consider a large number of urns containing balls of various colours. ... Looking at the raw data, I suspect that the numbers balls of different ... I might estimate the correlation ...
    (sci.stat.math)
  • Re: Placing Balls in Urns and Expected values
    ... urns, if balls are indexed, too. ... there are n possibilities how to place all balls into ... To compute probability, ... Any distinction vanishes. ...
    (sci.math)
  • Re: Help with Urn Problem
    ... number of SINGLY occuppied urns when M balls are randomly placed into N ... exactly one ball, and find the probability that exactly K, ... Herman Rubin, Department of Statistics, Purdue University ...
    (sci.stat.math)