def __init__(self): self.hoursOpen = D.HOURS_OPEN self.nExamRooms = D.N_EXAM_ROOMS self.arrivalTimeDist = RVGs.Exponential(scale=D.MEAN_ARRIVAL_TIME) self.examTimeDist = RVGs.Exponential(scale=D.MEAN_EXAM_DURATION) self.probDepression = D.PROB_DEPRESSION self.mentalHealthConsultDist = RVGs.Exponential( scale=D.MEAN_MH_CONSULT)
def test_exponential(rnd, scale, loc=0): # exponential random variate generator exp_dist = RVGs.Exponential(scale, loc) # obtain samples samples = get_samples(exp_dist, rnd) # report mean and variance print_test_results('Exponential', samples, expectation=scale + loc, variance=scale**2)
def __init__(self, rows, list_x_min, list_x_max, list_x_delta): """ :param rows: (list of list) the table above :param list_x_min: list of minimum value of x (in example above: [0, 0]) :param list_x_max: list of maximum value of x (in example above: [10, 1]) :param list_x_delta: list of interval between break points of x if set to 'int', x is treated as categorical variable (in example above: [5, 'int']) """ DataFrameOfObjects.__init__(self, list_x_min=list_x_min, list_x_max=list_x_max, list_x_delta=list_x_delta) for row in rows: self.set_obj(x_value=row[0:-1], obj=RVGs.Exponential(scale=1 / row[-1]))
def __init__(self, y_values, x_min=0, x_max=1, x_delta=1): """ :param y_values: (list) of rates (in example above: [0.1, 0.2, 0.3] :param x_min: minimum value of x (in example above: 0) :param x_max: maximum value of x (in example above: 10) :param x_delta: interval between break points of x (in example above: 5) if set to 'int', x is treated as categorical variable """ # create the list of exponential distributions y_objects = [] for v in y_values: if v <= 0: raise ValueError( 'All y_values (rates of exponential distributions) should be greater than 0.' ) y_objects.append(RVGs.Exponential(scale=1 / v)) OneDimDataFrame.__init__(self, y_objects=y_objects, x_min=x_min, x_max=x_max, x_delta=x_delta)
def test_fitting_exponential(): print("\nTesting Exponential with scale=0.5, loc=2") dist = RVGs.Exponential(scale=0.5, loc=2) print(' percentile interval: ', dist.get_percentile_interval(alpha=0.05)) data = np.array(get_samples(dist, np.random)) # method of moment dict_mm_results = RVGs.Exponential.fit_mm(mean=np.average(data), fixed_location=2) # maximum likelihood dict_ml_results = RVGs.Exponential.fit_ml(data=data, fixed_location=2) print(" Fit:") print(" MM:", dict_mm_results) print(" ML:", dict_ml_results) # plot the fitted distributions Plot.plot_exponential_fit(data=data, fit_results=dict_mm_results, title='Method of Moment') Plot.plot_exponential_fit(data=data, fit_results=dict_ml_results, title='Maximum Likelihood')