parameters: (self, candidate, parameters)
return_statement: return candidate
docstring: Randomly perturbs candidate parameters by perturbation factors.
  
          Args:
              candidate (dict): candidate parameter configuration.
              parameters (list[sherpa.core.Parameter]): parameter ranges.
  
          Returns:
              dict: perturbed parameter configuration.
docstring_summary: Randomly perturbs candidate parameters by perturbation factors.
docstring_tokens: Randomly perturbs candidate parameters by perturbation factors .
function: def _perturb(self, candidate, parameters):
          """
          Randomly perturbs candidate parameters by perturbation factors.
  
          Args:
              candidate (dict): candidate parameter configuration.
              parameters (list[sherpa.core.Parameter]): parameter ranges.
  
          Returns:
              dict: perturbed parameter configuration.
          """
          for param in parameters:
              if isinstance(param, Continuous) or isinstance(param, Discrete):
                  factor = sherpa_rng.choice(self.perturbation_factors)
                  candidate[param.name] *= factor
  
                  if isinstance(param, Discrete):
                      candidate[param.name] = int(candidate[param.name])
  
                  candidate[param.name] = numpy.clip(candidate[param.name],
                                                     min(self.parameter_range.get(param.name) or param.range),
                                                     max(self.parameter_range.get(param.name) or param.range))
  
              elif isinstance(param, Ordinal):
                  shift = sherpa_rng.choice([-1, 0, +1])
                  values = self.parameter_range.get(param.name) or param.range
                  newidx = values.index(candidate[param.name]) + shift
                  newidx = numpy.clip(newidx, 0, len(values)-1)
                  candidate[param.name] = values[newidx]
  
              elif isinstance(param, Choice):
                  candidate[param.name] = param.sample()
  
              else:
                  raise ValueError("Unrecognized Parameter Object.")
  
          return candidate
function_tokens: def _perturb ( self , candidate , parameters ) : for param in parameters : if isinstance ( param , Continuous ) or isinstance ( param , Discrete ) : factor = sherpa_rng . choice ( self . perturbation_factors ) candidate [ param . name ] *= factor if isinstance ( param , Discrete ) : candidate [ param . name ] = int ( candidate [ param . name ] ) candidate [ param . name ] = numpy . clip ( candidate [ param . name ] , min ( self . parameter_range . get ( param . name ) or param . range ) , max ( self . parameter_range . get ( param . name ) or param . range ) ) elif isinstance ( param , Ordinal ) : shift = sherpa_rng . choice ( [ - 1 , 0 , + 1 ] ) values = self . parameter_range . get ( param . name ) or param . range newidx = values . index ( candidate [ param . name ] ) + shift newidx = numpy . clip ( newidx , 0 , len ( values ) - 1 ) candidate [ param . name ] = values [ newidx ] elif isinstance ( param , Choice ) : candidate [ param . name ] = param . sample ( ) else : raise ValueError ( "Unrecognized Parameter Object." ) return candidate