lmpy.randomize.grady
Randomize PAMs using CJ’s algorithm.
This module contains functions used to randomize a PAM using CJ’s algorithm. This algorithm can run in a parallel fashion and uses a fill-based approach so as to prevent a bias caused by starting with an initial condition of a populated matrix.
Module Contents
Functions
|
Creates a two-dimensional approximation composed of all ones. |
|
Creates a two-dimensional approximation composed of all zeros. |
|
Create an approximation with the correct number of 1s randomly placed. |
|
Main function for creating a random matrix. |
|
Weighting method using max weight between row and column. |
|
Weighting method using max weight between row and column. |
|
Create an approximation using the total fill percentage of the PAM. |
- lmpy.randomize.grady.all_ones_heuristic(orig_pam)[source]
Creates a two-dimensional approximation composed of all ones.
- Parameters
orig_pam (
Matrix) – The observed PAM to randomize.- Returns
An approximate randomization of the PAM that is uncorrected.
- Return type
- lmpy.randomize.grady.all_zeros_heuristic(orig_pam)[source]
Creates a two-dimensional approximation composed of all zeros.
- Parameters
orig_pam (
Matrix) – The observed PAM to randomize.- Returns
An approximate randomization of the PAM that is uncorrected.
- Return type
- lmpy.randomize.grady.fill_shuffle_reshape_heuristic(orig_pam)[source]
Create an approximation with the correct number of 1s randomly placed.
Creates an array with the total number of ones from the original PAM and shuffles it then it reshapes it to match the shape of the original PAM.
- lmpy.randomize.grady.grady_randomize(mtx, approximation_heuristic=total_fill_percentage_heuristic)[source]
Main function for creating a random matrix.
- Parameters
mtx (
Matrix) – A Matrix object representation of a PAMapproximation_heuristic (
Method) – A function that generates an approximation of a final randomized matrix.
- Returns
- A matrix of random presence absence values with the same
marginal totals as the input matrix ‘mtx’.
- Return type
- lmpy.randomize.grady.max_col_or_row_heuristic(orig_pam)[source]
Weighting method using max weight between row and column.
This method returns a matrix of weights where the weight of each cell is the maximum between the proportions of the row and col
- Parameters
orig_pam (
Matrix) – The observed PAM to randomize.- Returns
An approximate randomization of the PAM that is uncorrected.
- Return type
- lmpy.randomize.grady.min_col_or_row_heuristic(orig_pam)[source]
Weighting method using max weight between row and column.
This method returns a matrix of weights where the weight of each cell is the maximum between the proportions of the row and col
- Parameters
orig_pam (
Matrix) – The observed PAM to randomize.- Returns
An approximate randomization of the PAM that is uncorrected.
- Return type
- lmpy.randomize.grady.total_fill_percentage_heuristic(orig_pam)[source]
Create an approximation using the total fill percentage of the PAM.
Creates an approximation using the total matrix fill of the original PAM as a weight threshold to compare with randomly generated numbers.
- Parameters
orig_pam (
Matrix) – The observed PAM to randomize.- Returns
An approximate randomization of the PAM that is uncorrected.
- Return type