Mean Values of Function

average_value_derivative(equation_type, coefficients, start, end, precision=4)

Evaluates the average rate of change between two points for a given function

Parameters
  • equation_type (str) – Name of the type of function for which the definite integral must be evaluated (e.g., ‘linear’, ‘quadratic’)

  • coefficients (list of int or float) – Coefficients of the original function to use for evaluating the average rate of change

  • start (int or float) – Value of the x-coordinate of the first point to use for evaluating the rate of change

  • end (int or float) – Value of the x-coordinate of the second point to use for evaluating the rate of change

  • precision (int, default=4) – Maximum number of digits that can appear after the decimal place of the result

Raises
  • ValueError – First argument must be either ‘linear’, ‘quadratic’, ‘cubic’, ‘hyperbolic’, ‘exponential’, ‘logarithmic’, ‘logistic’, or ‘sinusoidal’

  • TypeError – Second argument must be a 1-dimensional list containing elements that are integers or floats

  • TypeError – Third and fourth arguments must be integers or floats

  • ValueError – Third argument must be less than or equal to fourth argument

  • ValueError – Last argument must be a positive integer

Returns

average – Slope of a function between two points; if start and end values are identical, then slope will be zero

Return type

float

Notes

Examples

Import average_value_derivative function from regressions library
>>> from regressions.analyses.mean_values import average_value_derivative
Evaluate the average rate of change of a cubic function with coefficients 2, 3, 5, and 7 between end points of 10 and 20
>>> average_cubic = average_value_derivative('cubic', [2, 3, 5, 7], 10, 20)
>>> print(average_cubic)
1495.0
Evaluate the average rate of change of a sinusoidal function with coefficients 2, 3, 5, and 7 between end points of 10 and 20
>>> average_sinusoidal = average_value_derivative('sinusoidal', [2, 3, 5, 7], 10, 20)
>>> print(average_sinusoidal)
0.0401
mean_values_derivative(equation_type, coefficients, start, end, precision=4)

Generates a list of all the x-coordinates whose instantaneous rates of change equal the function’s average rate of change between two points

Parameters
  • equation_type (str) – Name of the type of function for which an average value must be determined (e.g., ‘linear’, ‘quadratic’)

  • coefficients (list of int or float) – Coefficients to use to generate the equation to investigate

  • start (int or float) – Value of the x-coordinate of the first point to use for evaluating the rate of change; all results must be greater than this value

  • end (int or float) – Value of the x-coordinate of the second point to use for evaluating the rate of change; all results must be less than this value

  • precision (int, default=4) – Maximum number of digits that can appear after the decimal place of the result

Raises
  • ValueError – First argument must be either ‘linear’, ‘quadratic’, ‘cubic’, ‘hyperbolic’, ‘exponential’, ‘logarithmic’, ‘logistic’, or ‘sinusoidal’

  • TypeError – Second argument must be a 1-dimensional list containing elements that are integers or floats

  • TypeError – Third and fourth arguments must be integers or floats

  • ValueError – Third argument must be less than or equal to fourth argument

  • ValueError – Last argument must be a positive integer

Returns

points – Values of the x-coordinates within the specified interval at which the original function has an instantaneous rate of change equal to its average rate of change over that entire interval; if the function is sinusoidal, then only the initial results within at most a four-period interval within the specified interval will be listed, but general forms will also be included (however, their results may be outside the specified interval); if the algorithm cannot determine any values, then it will return a list of None

Return type

list of float or str

Notes

Examples

Import mean_values_derivative function from regressions library
>>> from regressions.analyses.mean_values import mean_values_derivative
Generate a list of all the x-coordinates whose instantaneous rates of change equal the function’s average rate of change for a cubic function with coefficients 2, 3, 5, and 7 between end points of 10 and 20
>>> points_cubic = mean_values_derivative('cubic', [2, 3, 5, 7], 10, 20)
>>> print(points_cubic)
[15.2665]
Generate a list of all the x-coordinates whose instantaneous rates of change equal the function’s average rate of change for a cubic function with coefficients 2, 3, 5, and 7 between end points of 10 and 20
>>> points_sinusoidal = mean_values_derivative('sinusoidal', [2, 3, 5, 7], 10, 20)
>>> print(points_sinusoidal)
[10.7618, 11.8046, 12.8562, 13.899, 14.9506, 15.9934, 17.045, 18.0878, 19.1394, '10.7618 + 2.0944k', '11.8046 + 2.0944k']
average_value_integral(equation_type, coefficients, start, end, precision=4)

Evaluates the average value of a given function between two points

Parameters
  • equation_type (str) – Name of the type of function for which the definite integral must be evaluated (e.g., ‘linear’, ‘quadratic’)

  • coefficients (list of int or float) – Coefficients of the original function to integrate

  • start (int or float) – Value of the x-coordinate of the first point to use for evaluating the average value

  • end (int or float) – Value of the x-coordinate of the second point to use for evaluating the average value

  • precision (int, default=4) – Maximum number of digits that can appear after the decimal place of the result

Raises
  • ValueError – First argument must be either ‘linear’, ‘quadratic’, ‘cubic’, ‘hyperbolic’, ‘exponential’, ‘logarithmic’, ‘logistic’, or ‘sinusoidal’

  • TypeError – Second argument must be a 1-dimensional list containing elements that are integers or floats

  • TypeError – Third and fourth arguments must be integers or floats

  • ValueError – Third argument must be less than or equal to fourth argument

  • ValueError – Last argument must be a positive integer

Returns

average – Average value of the function between two points; if start and end values are identical, then average value will be zero

Return type

float

Notes

Examples

Import average_value_integral function from regressions library
>>> from regressions.analyses.mean_values import average_value_integral
Evaluate the average value of a cubic function with coefficients 2, 3, 5, and 7 between end points of 10 and 20
>>> average_cubic = average_value_integral('cubic', [2, 3, 5, 7], 10, 20)
>>> print(average_cubic)
8282.0
Evaluate the average value of a sinusoidal function with coefficients 2, 3, 5, and 7 between end points of 10 and 20
>>> average_sinusoidal = average_value_integral('sinusoidal', [2, 3, 5, 7], 10, 20)
>>> print(average_sinusoidal)
6.9143
mean_values_integral(equation_type, coefficients, start, end, precision=4)

Generates a list of all the x-coordinates between two points at which a function’s value will equal its average value over that interval

Parameters
  • equation_type (str) – Name of the type of function for which an average value must be determined (e.g., ‘linear’, ‘quadratic’)

  • coefficients (list of int or float) – Coefficients of the origianl function under investigation

  • start (int or float) – Value of the x-coordinate of the first point to use for evaluating the average value; all results must be greater than this value

  • end (int or float) – Value of the x-coordinate of the second point to use for evaluating the average value; all results must be less than this value

  • precision (int, default=4) – Maximum number of digits that can appear after the decimal place of the result

Raises
  • ValueError – First argument must be either ‘linear’, ‘quadratic’, ‘cubic’, ‘hyperbolic’, ‘exponential’, ‘logarithmic’, ‘logistic’, or ‘sinusoidal’

  • TypeError – Second argument must be a 1-dimensional list containing elements that are integers or floats

  • TypeError – Third and fourth arguments must be integers or floats

  • ValueError – Third argument must be less than or equal to fourth argument

  • ValueError – Last argument must be a positive integer

Returns

points – Values of the x-coordinates within the specified interval at which the original function has a value equal to its average value over that entire interval; if the function is sinusoidal, then only the initial results within at most a four-period interval within the specified interval will be listed, but general forms will also be included (however, their results may be outside the specified interval); if the algorithm cannot determine any values, then it will return a list of None

Return type

list of float or str

Notes

Examples

Import mean_values_integral function from regressions library
>>> from regressions.analyses.mean_values import mean_values_integral
Generate a list of all the x-coordinates of a cubic function with coefficients 2, 3, 5, and 7 at which the function’s value will equal its average value between 10 and 20
>>> points_cubic = mean_values_integral('cubic', [2, 3, 5, 7], 10, 20)
>>> print(points_cubic)
[15.5188]
Generate a list of all the x-coordinates of a sinusoidal function with coefficients 2, 3, 5, and 7 at which the function’s value will equal its average value between 10 and 20
>>> points_sinusoidal = mean_values_integral('sinusoidal', [2, 3, 5, 7], 10, 20)
>>> print(points_sinusoidal)
[10.2503, 11.2689, 12.3447, 13.3633, 14.4391, 15.4577, 16.5335, 17.5521, 18.6279, 19.6465, '10.2503 + 2.0944k', '11.2689 + 2.0944k']
average_values(equation_type, coefficients, start, end, precision=4)

Calculates the average values for a specific function

Parameters
  • equation_type (str) – Name of the type of function for which average values must be determined (e.g., ‘linear’, ‘quadratic’)

  • coefficients (list of int or float) – Coefficients of the origianl function under investigation

  • start (int or float) – Value of the x-coordinate of the first point to use for evaluating the average values; results within lists must be greater than this value

  • end (int or float) – Value of the x-coordinate of the second point to use for evaluating the average values; results within lists must be less than this value

  • precision (int, default=4) – Maximum number of digits that can appear after the decimal place of the result

Raises
  • ValueError – First argument must be either ‘linear’, ‘quadratic’, ‘cubic’, ‘hyperbolic’, ‘exponential’, ‘logarithmic’, ‘logistic’, or ‘sinusoidal’

  • TypeError – Second argument must be a 1-dimensional list containing elements that are integers or floats

  • TypeError – Third and fourth arguments must be integers or floats

  • ValueError – Third argument must be less than or equal to fourth argument

  • ValueError – Last argument must be a positive integer

Returns

  • averages[‘average_value_derivative’] (float) – Slope of a function between two points

  • averages[‘mean_values_derivative’] (list of float or str) – Values of the x-coordinates within the specified interval at which the original function has a value equal to its average value over that entire interval; if the function is sinusoidal, then only the initial results within at most a four-period interval within the specified interval will be listed, but general forms will also be included (however, their results may be outside the specified interval); if the algorithm cannot determine any values, then it will return a list of None

  • averages[‘average_value_integral’] (float) – Average value of the function between two points

  • averages[‘mean_values_integral’] (list of float or str) – Values of the x-coordinates within the specified interval at which the original function has a value equal to its average value over that entire interval; if the function is sinusoidal, then only the initial results within at most a four-period interval within the specified interval will be listed, but general forms will also be included (however, their results may be outside the specified interval); if the algorithm cannot determine any values, then it will return a list of None

Notes

Examples

Import average_values function from regressions library
>>> from regressions.analyses.mean_values import average_values
Calculate the averages of a cubic function with coefficients 2, 3, 5, and 7 between 10 and 20
>>> averages_cubic = average_values('cubic', [2, 3, 5, 7], 10, 20)
>>> print(averages_cubic['average_value_derivative'])
1495.0
>>> print(averages_cubic['mean_values_derivative'])
[15.2665]
>>> print(averages_cubic['average_value_integral'])
8282.0
>>> print(averages_cubic['mean_values_integral'])
[15.5188]
Calculate the averages of a sinusoidal function with coefficients 2, 3, 5, and 7 between 10 and 20
>>> averages_sinusoidal = average_values('sinusoidal', [2, 3, 5, 7], 10, 20)
>>> print(averages_sinusoidal['average_value_derivative'])
0.0401
>>> print(averages_sinusoidal['mean_values_derivative'])
[10.7618, 11.8046, 12.8562, 13.899, 14.9506, 15.9934, 17.045, 18.0878, 19.1394, '10.7618 + 2.0944k', '11.8046 + 2.0944k']
>>> print(averages_sinusoidal['average_value_integral'])
6.9143
>>> print(averages_sinusoidal['mean_values_integral'])
[10.2503, 11.2689, 12.3447, 13.3633, 14.4391, 15.4577, 16.5335, 17.5521, 18.6279, 19.6465, '10.2503 + 2.0944k', '11.2689 + 2.0944k']