Guide to numerical transformations¶
Following numerical transformations are currently defined in the
HARDy
-
hardy.arbitrage.transformations.cumsum(raw_array)[source]¶ The function return the cumulative sum of input array
Parameters: - raw_array: Input numpy array
Returns: - cumsum _array: np.ndarray
cumulative sum of values in the input array
Notes
\[Z = [Z_1, Z_1+Z_2, Z_1+Z_2+Z_3, Z_1+...+Z_n]\]
-
hardy.arbitrage.transformations.cwt_1d(raw_df, xy=0)[source]¶ Transform to execute a “Continuous Wavelet Transform” on a 1d data array pass it a raw XY data and tell it which column to use for the transform. See Documentaion on CWT transform: https://docs.scipy.org/doc/scipy/reference/generated/ scipy.signal.cwt.html#scipy.signal.cwt Note: I need to do testing to understand the in/outputs here… Plan is to simply hard-code a certain type of Wavelet to use… and Output Data may not be able to be square… In that case, we will discuss how to integrate this result with the compression of the data.
Parameters: - raw_df: pandas.DataFrame or 1D array (Mx2 or Mx1)
the raw data which is to be transformed.
- xy: boolean, or string ‘x’, or ‘y’
information on which dataframe column to transform. ignored if an 1D array is passed instead.
- w_method: string or boolean?
input instructions guiding how to choose wavelet sizes. default should be linear, with options for log- or exponential? (Will have to experiment with data to discover best option)
Returns: - cwt_matrix: np.ndarray (MxM)
Square M-by-M matrix of the wavelet transform data (Not yet compressed to plottable 0-1 data)
-
hardy.arbitrage.transformations.derivative_1d(raw_array, spacing=0)[source]¶ Function that outputs the gradient of 1-D array using numpy.gradient function
Parameters: - raw_array: numpy array
- spacing: int representing the spacing between each datapoint
Returns: - derivative_array: np.ndarray
array representing gradient at each datapoint
Notes
\[f_{(0)}^{(1)} = \frac{f(x+1)-f(x-1)}{2h}\]where \(h = [0, 1, 2, 3, ..., size-1]\)
-
hardy.arbitrage.transformations.derivative_2d(x, y, meta_data=None)[source]¶ Function that outputs the slope between x and y data
Parameters: - x: numpy.array
array representing values on x-axis
- y: numpy.array
array representing values on y-axis
Returns: - slope_array: numpy.array
array representing the slope between x and y
Notes
\[Z = [ \frac{Y_{(i+1)}-Y_{(i)}}{X_{(i+1)}-X_{(i)}}, ... ,0]\]
-
hardy.arbitrage.transformations.exp(raw_array)[source]¶ Function that returns the exponent of individual elements in the array
Parameters: - raw_array: numpy.array
array representing data values
Returns: - exp_array: numpy.array
array representing the exponentials of data values
Notes
\[Z = \exp{Z}\]
-
hardy.arbitrage.transformations.log10(raw_array)[source]¶ The function that outputs the natural log of input array
Parameters: - raw_array: Input numpy array
Returns: - log_array: np.ndarray
natural log values of each element in the input array
- Notes
\[Z = \log{Z}\]
-
hardy.arbitrage.transformations.nlog(raw_array)[source]¶ The function that outputs the natural log of input array
Parameters: - raw_array: Input numpy array
Returns: - log_array: np.ndarray
natural log values of each element in the input array
Notes
\[Z = \ln{Z}\]
-
hardy.arbitrage.transformations.power(x, y='None', meta_data=None)[source]¶ Function that multiplies two arrays x^m & y^n, element by element. If y is None, it return x*x
Parameters: - x: numpy.array
numpy array representing the one array to be multiplied
- y: numpy.array
numpy array representing the second array to be multiplied if None it the module will square the x array
- meta_data: numpy.array
- [m, n] where m is the power of x, and n is the power
of y. If none, m=1 and n=1
Returns: - multi_array: numpy.array
numpy array representing the one to one multiplication of two arrays
Notes
\[Z = X^m*Y^n\]if \(Y=0\)
\[Z = X^m\]
-
hardy.arbitrage.transformations.raw(raw_array)[source]¶ Function that provides returns data as it is
Parameters: - raw_array: numpy.array
array representing data values
Returns: - raw_array: numpy.array
array representing data values
Notes
\[Z = Z\]
-
hardy.arbitrage.transformations.reciprocal(raw_array)[source]¶ The function the outputs the reciprocal of input array
Parameters: - raw_array: Input numpy array
Returns: - reciprocal_array: np.ndarray
reciprocal values of each element in the input array
Notes
\[Z = \frac{1}{Z}\]
Defining numerical transformations¶
User defined numerical transformations can be integrated in the
HARDy by integrating the transformation definition
inside the hardy.arbitrage.transformations module. The
example transformation definition is shown below:
def transformation_function(args):
y = f(x)
Most of the transformations defined in HARDy are one
dimensional transformations i-e they require only one arguments.
If the user want to include more than one argument and metadata
(exponents), refer to function definition of power or
derivative_2d defined in hardy.arbitrage.transformations
module. If the metadata is different than the length of metadata in
power, function apply_tform in
hardy.arbitrage.arbitrage needs to be modified
accordingly as well.