In order to curiosity:
In case of weight of an object in "very light", "light", "medium", "heavy" and "very heavy". We can use some statistical methods to define a range.
So if we have 50 products, with the following weight list:
1, 1, 1, 3, 4, 4, 5, 5, 6, 6,
7, 7, 7, 7, 7, 8, 8, 8, 9, 9,
10, 10, 10, 10, 11, 15, 16, 16, 16, 17,
18, 18, 18, 18, 18, 40, 40, 40, 40, 40,
47, 47, 49, 49, 50, 55, 58, 59, 90.
We have the highest value as 90 and the smallest as 1, so our sampling amplitude is AA = 89 (90-1).
Then we calculate i, which theoretically would be the number of clusters we need to have: i = 1 + 3.3 log 50 = 6.6 ~ 7 (normal rounding).
So the ideal would be to have 7 weight classifications, but for this example we will use the 5 already classified by you, so consider i = 5.
Now we need to calculate what the intervals will be.
AA / i = 89/5 = 17.8 ~ 18 (always rounded up).
Very Light: 1 | - 19
Light: 19 | - 37
Average: 37 | - 55
Heavy: 55 | - 73
Very Heavy: 73 | - 91
<?php
abstract class Peso
{
public getStringValue($value)
{
if ($value < 19){
return "Muito Leve";
}elseif($value < 37){
return "Leve";
}elseif($value < 55){
return "Médio";
}elseif($value < 73){
return "Pesado";
}else{
return "Muito Pesado";
}
}
}
?>