def quintic_curve_fitting_and_plotting(ind_filename: str, dep_filename: str) -> None: """Graph a scatter plot and a quintic curve of best fit of the independent and dependent variables indicated by ind_filename and dep_filename respectively Preconditions: - ind_filename != '' - dep_filename != '' """ independent_name = pd_with_pandas.get_name( ind_filename) # title for the x-axis lists = pd_with_pandas.filenames_to_lists(ind_filename, dep_filename) ind_list, dep_list = lists[0], lists[1] n = len(ind_list) y_values = [] variables = curve_fit(quintic_function, ind_list, dep_list) for i in range(n): y_value = quintic_function(ind_list[i], variables[0][0], variables[0][1], variables[0][2], variables[0][3], variables[0][4], variables[0][5]) y_values.append(y_value) variables = (ind_list, dep_list, y_values) plotting_data_with_curve(independent_name, variables)
def exponential_equation_of_best_fit(ind_filename: str, dep_filename: str) -> str: """Returns the exponential equation of best fit as a string for the dependent and independent variables indicated by dep_filename and ind_filename respectively Preconditions: - independent_name != '' - variables != () """ lists = pd_with_pandas.filenames_to_lists(ind_filename, dep_filename) ind_list, dep_list = lists[0], lists[1] optimal_values, covariance = curve_fit(exponential_function, ind_list, dep_list) return 'y = ' + str(optimal_values[0]) + ' ^ x ' + ' + ' + str(optimal_values[1])