# How to determinate standard deviation above and below mean classes programatically

I have an array of float from wich I calculate the mean and the standard deviation. The user can specify a number of class varying between 2 and 8. The min and max values of each class is calculated by a number of standard deviation above and below the mean.

Ex:

nbr_classes = 4;
mean = 10;
min_value = 1
max_value = 10
std_deviation = 2

class_1_min = min_value
class_1_max = mean - 2*std_deviation

class_2_min = class_1_max
class_2_max = mean - std_deviation

class_3_min = class_2_max
class_3_max = mean + std_deviation

class_4_min = class_3_max
class_4_max = max_value


I would like to create a function that would do that programatically, knowing that number of classes can be odd