Range of Data Set

range_value(data)

Determines the range of a data set (i.e., the difference between its largest value and its smallest value)

Parameters

data (list of int or float) – List of numbers to analyze

Raises
  • TypeError – Argument must be a 1-dimensional list

  • TypeError – Elements of argument must be integers or floats

Returns

interval – Range of data set

Return type

float

Notes

  • Set of numbers: \(a_i = \{ a_1, a_2, \cdots, a_n \}\)

  • Range of set: \(R = a_{max} - a_{min}\)

    • \(a_{min} \leq a_j, \forall a_j \in a_i\)

    • \(a_{max} \geq a_j, \forall a_j \in a_i\)

  • Range

Examples

Import range_value function from regressions library
>>> from regressions.statistics.ranges import range_value
Determine the range of the set [21, 53, 3, 68, 43, 9, 72, 19, 20, 1]
>>> range_even = range_value([21, 53, 3, 68, 43, 9, 72, 19, 20, 1])
>>> print(range_even)
71.0
Determine the range of the set [12, 81, 13, 8, 42, 72, 91, 20, 20]
>>> range_odd = range_value([12, 81, 13, 8, 42, 72, 91, 20, 20])
>>> print(range_odd)
83.0
shift_into_range(initial_value, periodic_unit, minimum, maximum)

Adjusts an intial value to one within a particular range by increasing or decreasing its value by a specified unit

Parameters
  • initial_value (int or float) – Starting value to adjust to fit into a range

  • periodic_unit (int or float) – Unit by which the initial value should be incrementally increased or decreased to fit into a range

  • minimum (int or float) – Lower bound of range into which the initial value must be adjusted (final value should be greater than or equal to minimum)

  • maximum (int or float) – Upper bound of range into which the initial value must be adjusted (final value should be less than or equal to maximum)

Raises
  • TypeError – Arguments must be integers or floats

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

Returns

final_value – Value within range that only differs from the initial value by a an integral multiple of the periodic unit

Return type

float

See also

shifted_points_within_range(), mean_values_derivative(), mean_values_integral()

Notes

  • Initial value: \(v_i\)

  • Periodic unit: \(\lambda\)

  • Lower bound of range: \(b_l\)

  • Upper bound of range: \(b_u\)

  • Set of all values derived from initial value and periodic unit: \(g = \{ v \mid v = v_i + \lambda\cdot{k} \}\)

    • \(k \in \mathbb{Z}\)

  • Final value: \(v_f \geq b_l \cap v_f \leq b_u \cap v_f \in g\)

Examples

Import shift_into_range function from regressions library
>>> from regressions.statistics.ranges import shift_into_range
Adjust the number 7 to a value between 20 and 30, based on a periodic unit of 8
>>> final_value_int = shift_into_range(7, 8, 20, 30)
>>> print(final_value_int)
23.0
Adjust the number 524.62 to a value between 138.29 and 213.86, based on a periodic unit of 23.91
>>> final_value_float = shift_into_range(524.62, 23.91, 138.29, 213.86)
>>> print(final_value_float)
213.78999999999974