equation to calculate intervals based on dynamic data

I am looking for an equation to calculate appropriate intervals to designate values as very low, low, medium, high, very high for dynamic data.

for example if my dataset ranges from 0 to 100 very low= <=20, low=21-40, medium=41-60, high=61-80, very high= >81

However, if the range is small there should be fewer ranges. For example, if the range is 20 then there should be a low and high interval designation only.

the intervals need to be logical intervals so they can be used for a graphical display. logical intervals would include intervals of 5, 10, 25, 50, 100 etc depending on the dataset. Is there an equation that can determine appropriate intervals for each unique dataset?

-
 If this is for programming purposes, what's wrong with if-then-else (or switch or whatever multibranching construct your language supplies)? – J. M. Jul 28 '11 at 15:06 Since there's 5 ranges, divide the total range by 5 and then round it to a multiple of 5 or 10 or whatever, and adjust. Like if the range is 200 to 575, that's 375/5=75 so 200-275, 276-350, 351-425, 426-500,501-575. If the data's spread out exponentially you might want to put it on a logarithmic scale first if that makes sense... – user826788 Jul 28 '11 at 15:14 You may also consider asking this question over at Stats.Stackexchange. – Willie Wong♦ Jul 28 '11 at 16:04