Generate a Vector¶
- generate_elements(initial_value, periodic_unit, precision=4)¶
Generates a vector containing an initial numerical value, four additional numerical values created by incrementing the initial value by a periodic unit four times, and a string value for the general form of all values in the vector, made up of a multiple of the periodic unit added to the initial value; any negative periodic units will be converted their absolute values before any other evaluations occur
- 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
precision (int, default=4) – Upper bound of range into which the initial value must be adjusted (final value should be less than or equal to maximum)
- Raises
TypeError – First and second arguments must be integers or floats
ValueError – Last argument must be a positive integer
- Returns
generated_vector – Vector containing five numerical values, each a set incremenent apart from one another, and a string value representing the general form of all numerical elements in the vector as well as any additional numerical elements that could be generated from it in the future
- Return type
list of float
See also
shift_into_range(),shifted_points_within_range(),sinusoidal_roots()Notes
Initial value: \(v_i\)
Periodic unit: \(\lambda\)
Set of all values derived from initial value and periodic unit: \(g = \{ v \mid v = v_i + \lambda\cdot{k} \}\)
\(k \in \mathbb{Z}\)
Examples
- Import generate_elements function from regressions library
>>> from regressions.vectors.generate import generate_elements
- Generate a vector of elements based off an initial value of 3 and a periodic unit of 2
>>> generated_vector_int = generate_elements(3, 2) >>> print(generated_vector_int) [3.0, 5.0, 7.0, 9.0, 11.0, '3.0 + 2.0k']
- Generate a vector of elements based off an initial value of 3 and a periodic unit of -2
>>> generated_vector_neg = generate_elements(3, -2) >>> print(generated_vector_neg) [3.0, 5.0, 7.0, 9.0, 11.0, '3.0 + 2.0k']
- Generate a vector of elements based off an initial value of 17.23 and a periodic unit of 5.89
>>> generated_vector_float = generate_elements(17.23, 5.89) >>> print(generated_vector_float) [17.23, 23.12, 29.01, 34.9, 40.79, '17.23 + 5.89k']