_arpack.py 1.1 KB

123456789101112131415161718192021222324252627282930
  1. from .validation import check_random_state
  2. def _init_arpack_v0(size, random_state):
  3. """Initialize the starting vector for iteration in ARPACK functions.
  4. Initialize a ndarray with values sampled from the uniform distribution on
  5. [-1, 1]. This initialization model has been chosen to be consistent with
  6. the ARPACK one as another initialization can lead to convergence issues.
  7. Parameters
  8. ----------
  9. size : int
  10. The size of the eigenvalue vector to be initialized.
  11. random_state : int, RandomState instance or None, default=None
  12. The seed of the pseudo random number generator used to generate a
  13. uniform distribution. If int, random_state is the seed used by the
  14. random number generator; If RandomState instance, random_state is the
  15. random number generator; If None, the random number generator is the
  16. RandomState instance used by `np.random`.
  17. Returns
  18. -------
  19. v0 : ndarray of shape (size,)
  20. The initialized vector.
  21. """
  22. random_state = check_random_state(random_state)
  23. v0 = random_state.uniform(-1, 1, size)
  24. return v0