I am working with a dataset which looks essentially like the following:

Name     Average Score
-------- --------------
John     34.9381
Susan    22.2718
Stu      29.1009

The assumption is that each average score is composed of integer-value single scores.

I would like to know if there are any standard techniques out there for determining the quantity of data underlying the aggregates. For the purposes of simplification, we can assume that number of records is consistent among names.

I've tried a few hacked-together techniques for guessing, but the brute-force method of trying n=2, then 3, then 4, etc. of every possible value is computationally miserable for anything other than test cases.

I've also attempted to shave it down by assuming first value = round(average), then adding next value to get closest possible on n=2, etc. (e.g., 2.666: first is 3; for second, subtract 3/2 from 2.666, round to nearest 0.5, multiply by 2: result = 2, so best average=2.5; etc.).

This works for trivially simple numbers -- rather, single floats. Run until minimized, and it gives a rough idea for a small n. But this may be theoretically full of holes, which I'd like to know.

Worse, for many decimal places, large datasets, and lots of rounding problems, this ugly method isn't great. And I feel like I must be solving an already-solved problem, but I don't have the vocabulary even to search for the solution. What is this problem called, or even what field is this in? And does anyone have any bright ideas, R libraries, etc.?

Thanks very much.


1 Answer 1


One possibility is to generate fractions. You could use the function .rat, hidden in the package MASS, to find rational approximations to the components of a real numeric object.

scores <- c(34.9381, 22.2718, 29.1009)

res <- MASS:::.rat(scores)

This command will return the following list:

[1,] 349381 10000
[2,]  67684  3039
[3,] 291009 10000

[1] 34.9381 22.2718 29.1009

You could find the denominators in the second column (b0) of the matrix in $rat:

res$rat[ , "b0"]

Now, you could check which denominators are justified by the possible number of data points.

  • $\begingroup$ That's kind of perfect, I think. I'll check it out! $\endgroup$ Commented Feb 5, 2013 at 23:26
  • $\begingroup$ This looks like the right neck of the woods; it tends, however, to merely return fractions denominated by 1000, 10000, etc. Even passing max.denominator=999, I still get many with a power-of-10 denominator. Any ideas? $\endgroup$ Commented Feb 5, 2013 at 23:37
  • $\begingroup$ You could just use fractions from the MASS package (which is exported, not hidden) $\endgroup$
    – mnel
    Commented Feb 6, 2013 at 0:45
  • $\begingroup$ @mnel The function fractions will return the fractions as strings. I suppose its easier to use integers. $\endgroup$ Commented Feb 6, 2013 at 6:47
  • $\begingroup$ fractions, unfortunately, shows the same problem -- in the majority of the cases, it simply takes, e.g., 3.1415 and makes it 31415/10000. Is anyone aware of a technique for integrating findings from multiple numbers? These are actually great starting points for me to build a brute-force solution, but I'm also hoping to find out where and whether this specific problem has been dealt with in the past. Thanks again. $\endgroup$ Commented Feb 6, 2013 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.