Sign up ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

This is kind of a programming question, but really it's math in disguise!

I'm working on a little project that will look at the size of a file and make sure it's in within an acceptable range based on previous file sizes. I know how to get the average file size of previous files and all that.

I'm wondering if there is an equation or a method that I can dynamically create an acceptable range depending on avg file size, number of files, or some other statistical value. I can provide more details if needed, but I really don't know where to start.

share|cite|improve this question
I apologize if this is better suited for Statistical Analysis -- I figured Mathematics would cover that subset so I didn't really look further until after I posted. Migrate if necessary. – Shaded Feb 4 '11 at 15:36

2 Answers 2

up vote 2 down vote accepted

You may want to try testing whether the size of the file in question is within say 1 standard deviation of the average size.

share|cite|improve this answer
That will probably work, my only concern is in cases where the sample size is small. For example one case I have in testing my results give me an average size of 234 kB and a Standard Deviation of 204 kB which is kind of a huge range. Never-the-less thank you very much for the response! – Shaded Feb 4 '11 at 15:51

There are 8 bits are in a byte, so $2^{(n*8)}$ (where n is the number of bytes in the file) will get you the size of the total number of different possibilities there are for what the files content could be. And, to determine the number of possible contents for any file with a size (in bytes) $\leq$ n, then:


However, this is not an efficient storage method as the resulting integer (from $2^{(n*8)}$) will take as many bytes to store as the size of the file. And you cannot 'cheat' by using floating floint precision, because if you use it, then you wont be able to correctly store the data (maintain its correct value).

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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