Submodule generators¶
This module manage the creation of random circle in sparse matrix using numpy package.
- LordOfRings.generator.center_radius_generator(mu, sigma, rmin, rmax, n)¶
center_radius_generator generate three random numbers, two from a normal distribution and one from an uniform distribuion (with randint). The number extracted from the normal distribution are turned to integer values because we are working with matrix of integers.
- Parameters
- mufloat, greater than or equal to zero, lower than the grid linear size
The mean for the normal distribution.
- sigmafloat, positive value
The standard deviation for the normal distribution.
- rmaxfloat, positive value, greater than rmin
The maximum radius for the uniform extraction.
- rminfloat, greater than or equal to zero, lower than rmax
The minimum radius for the uniform extraction.
- nint
The linear size of the grid.
- Returns
- (1d numpy-array [int], int)
the first element of the returned tuple contain the center position, the second element contain the radius.
- LordOfRings.generator.circle_generator(n, c, r)¶
circle_generator create a sparse matrix nxn with values 0 or 1. The only elements of the matrix that are 1 belong to a circle of radius r and center c.
- Parameters
- nint
The linear size of the matrix
- c1d numpy array [float]
The center’s coordinates.
- rfloat
The radius of the circle.
- Returns
- 2d numpy-array [int]
The matrix of zeros containing the circle as 1 values.
- LordOfRings.generator.data_gen(n, ndata, ncircle, mu=None, sigma=None, rmin=None, rmax=None, threshold=0.3, seed=None, maxhits=64)¶
data_gen create set of data containing sparse matrixes of ones in txt format. Data are created in a folder named ‘data’ in the current directory.
- Parameters
- nint
The linear size of the grid.
- ndataint
The number of data set to generate.
- ncircleint
The number of circle in each sparse matrix.
- mufloat, greater than or equal to zero, lower than the grid linear size
The mean for the normal distribution.
- sigmafloat, positive value
The standard deviation for the normal distribution.
- rminfloat, greater than or equal to zero, lower than rmax
The minimum radius for the uniform extraction.
- rmaxfloat, positive value, greater than rmin
The maximum radius for the uniform extraction.
- thresholdfloat
Parameter that controll the extraction, i.e. lower values correspond to higer number of ones in the returned matrix and vice versa.
- seedint, default = None
The seed for the random numbers extraction for reproducibility.
- maxhitsint
The maximum number of ones in the sparse matrix. It’s recommended a value lower then n.
- Returns
- LordOfRings.generator.rnd_circle_pruning(circle, threshold=0.3, maxhits=64)¶
rnd_circle_pruning modifies the input sparse matrix randomly removing some ones that belongs to the ring. The random selection uses a uniform distribution.
- Parameters
- circle2d numpy-array [int]
The input sparse matrix that contains the ring as ones.
- thresholdfloat
Parameter that controll the extraction, i.e. lower values correspond to higer number of ones in the returned matrix and vice versa.
- maxhitsint
The maximum number of points after the second pruning. If a circle has more than maxhits points after the first pruning remove them randomly until they reach maxhits.
- Returns
- 2d numpy-array [int]
The matrix obtained from the random pruning.