bertini.randomยถ
- bertini.random.complex_bounded_modulus() bertini._pybertini.multiprec.complex_mp :ยถ
Make a random complex number of bounded modulus (box-uniform in [-1,1]x[-1,1], magnitude at most sqrt(2), away from 0 โ the Bertini coefficient draw), in the current default precision
- bertini.random.complex_in_minus_one_to_one() bertini._pybertini.multiprec.complex_mp :ยถ
Make a random complex number uniformly distributed in [-1,1]x[-1,1], in the current default precision
- bertini.random.complex_unit() bertini._pybertini.multiprec.complex_mp :ยถ
Make a random complex number of magnitude 1, in the current default precision
- bertini.random.conjugate_orthonormal_matrix((int)rows, (int)cols[, (bool)real=False]) numpy.ndarray :ยถ
A rows x cols random conjugate-orthonormal matrix (its rows orthonormal โ QR-factored from a square matrix of units, then truncated; perfectly conditioned), at the current default precision. real=True yields a real orthogonal matrix (entries with zero imaginary part). Returns a complex_mp matrix.
- bertini.random.derive_solve_seed() int :ยถ
Capture the session streamโs current position as an effective per-solve seed: one draw off the current stream (advancing it), nonzero, 32-bit portable. bertini.solve uses this when no explicit seed is given, so a recorded runโs seed reproduces that run standalone โ deterministic from the session master when one was set, random for a never-seeded session.
- bertini.random.get_random_seed() int :ยถ
Return the effective global RNG seed. If set_random_seed has not been called, draws from entropy on first call and caches the result.
- bertini.random.random_complex() bertini._pybertini.multiprec.complex_mp :ยถ
Make a random complex number (complex_mp) of bounded modulus (away from 0 and infinity), at the current default precision. Reproducible via set_random_seed.
- bertini.random.random_real() bertini._pybertini.multiprec.real_mp :ยถ
Make a random real number (real_mp) of bounded modulus (box-uniform in [-1,1], away from 0), at the current default precision. Reproducible via set_random_seed.
- bertini.random.random_vector((int)size[, (bool)real=False]) object :ยถ
A random length-size vector of bounded-modulus numbers โ real_mp when real=True, else complex_mp โ at the current default precision. The natural random projection / linear-functional coefficient vector (generic and seed-reproducible, unlike the quantized orthonormal random_matrix).
- bertini.random.real_as_complex() bertini._pybertini.multiprec.complex_mp :ยถ
Make a random real number in [-1,1], as a complex number with imaginary part 0, in the current default precision
- bertini.random.real_bounded_modulus() bertini._pybertini.multiprec.complex_mp :ยถ
Make a random real number of bounded modulus (box-uniform in [-1,1]), as a complex number with imaginary part 0, in the current default precision
- bertini.random.real_unit() bertini._pybertini.multiprec.complex_mp :ยถ
Make a random real number of unit modulus (i.e. +1 or -1), as a complex number with imaginary part 0, in the current default precision
- bertini.random.set_random_seed([(int)seed=0]) None :ยถ
Set the global RNG seed (0 = draw from entropy). Call before constructing any homotopy or solver to get reproducible results. The effective seed (which may differ from 0 when entropy is used) is retrievable via get_random_seed().
- bertini.random.random_matrix(rows, cols, real=False, units=False, orthonormal=True, symbolic=False)[source]ยถ
A
rowsxcolsrandom matrix, at the current default precision.The building block for a random linear form / projection / slice / patch โ they are all just linear functions, and โwhat you use them for is up to you.โ Returns a numpy array of arbitrary-precision values (
bertini.multiprec.Complex); passsymbolic=Trueto instead get coefficient nodes ready to drop straight into function-tree expressions.- Parameters:
rows (int) โ The shape of the matrix.
cols (int) โ The shape of the matrix.
real (bool, default False) โ When True the entries are real (zero imaginary part); otherwise complex.
units (bool, default False) โ When True (and not
orthonormal) each entry has modulus 1 (arealunit is +/-1); otherwise each entry is drawn with bounded modulus (box-uniform in [-1,1] per component).orthonormal (bool, default True) โ When True the rows are conjugate-orthonormal (QR-factored from a square matrix of units, then truncated โ perfectly conditioned).
real=Truegives a real orthogonal matrix.orthonormaltakes precedence overunits(orthonormal rows are already normalized).symbolic (bool, default False) โ When True, return a numpy object array of coefficient nodes (via
bertini.coefficients()); otherwise numericmultiprec.complex_mp.
Notes
Reproducible via
bertini.random.set_random_seed(). A projection is just a linear functional with zero constant term, so its gradient row is exactlyrandom_matrix(1, n).For a generic real direction (e.g. a real projection), prefer
bertini.random_vector()withreal=True: a real orthonormal matrix is QR-factored from a matrix of real units (+/-1), so its entries are quantized (a realrandom_matrix(3, 1)has entries +/-1/sqrt(3)) and look seed-independent โ fine for conditioning, but not a generic direction.random_vectordraws continuous bounded-modulus reals instead (generic and seed-reproducible).