can anyone help me with this?

let's say you have a rational number n

what's the best way of computing the shortest list of integers whose mean average is n?

the result could be represented as a list (where some numbers are stated multiple times) e.g:
n = 4.75
avg([7, 7, 4, 1]) = 4.75

or as a set of tuples where the second value is the number of times that number occurs, e.g:
n = 4.75
[ {7, 2}, {4, 1}, {1, 1} ]

· · Web · 0 · 0 · 0

this feels like some kind of factoring to me, but i don't know enough math to join That to This

@jk do you have a rational representation of the number? a/b?

@yatchi turns out not always :/ so it has to work for all real numbers

@jk @yatchi seems like you'd hit a problem with irrational real numbers if the mean is computed from integers? as that'd imply your mean is in Q, not R

@ninjawedding @jk yeah the average must be a rational number, you can't do this with an irrational number

@yatchi @ninjawedding accuracy isn't paramount so I can just truncate to a rational approximation anyway; it seems fairly workable

@jk @ninjawedding the shortest possible list will be produced by the best rational approximation which you can calculate with continued fractions

@yatchi @jk whoa, I haven't had an occasion to look continued fractions up in a *long* time. thanks for the pointers

@jk in any case, i think you get there by finding the sum and the number of integers that are in the list (and for any given sum you can trivially get a list by adding the right number of zeros. and work from there if you want one of the infinite other possibilities). if a/b is in simplest form then ab is the sum and b is the number of numbers required, because there is no smaller integer a/b can be multiplied by to produce an integer

@jk so for 4.75 = 19/4 you need four numbers that sum to 19, and there is no way to do it with fewer than four

and then if you want to do it for a real number the problem is then finding a rational representation of it

@jk I love this because I understand it to exist in the world that I exist in and I have absolutely no idea what even a rational number n might be.

The diversity of experience.

Sign in to participate in the conversation

The original server operated by the Mastodon gGmbH non-profit