class_docstr: Class defining mutations, and holding a random state used for random generation.
class_docstr_tok: ["Class","defining","mutations",",","and","holding","a","random","state","used","for","random","generation","."]
docstr: Doerr's recommendation above can mutate up to half variables
  in average.
  In our high-arity context, we might need more than that.
  
  Parameters
  ----------
  parent: array-like
      the point to mutate
  max_ratio: float (between 0 and 1)
      the maximum mutation ratio (careful: this is not an exact ratio)
docstr_tok: ["Doerr","'s","recommendation","above","can","mutate","up","to","half","variables","in","average",".","In","our","high-arity","context",",","we","might","need","more","than","that",".","Parameters","--","--","--","--","--","parent",":","array-like","the","point","to","mutate","max_ratio",":","float","(","between","0","and","1",")","the","maximum","mutation","ratio","(","careful",":","this","is","not","an","exact","ratio",")"]
code: def doubledoerr_discrete_mutation(
      self, parent: tp.ArrayLike, max_ratio: float = 1.0, arity: int = 2
  ) -> tp.ArrayLike:
      """Doerr's recommendation above can mutate up to half variables
      in average.
      In our high-arity context, we might need more than that.
  
      Parameters
      ----------
      parent: array-like
          the point to mutate
      max_ratio: float (between 0 and 1)
          the maximum mutation ratio (careful: this is not an exact ratio)
      """
      assert 0 <= max_ratio <= 1
      dimension = len(parent)
      max_mutations = max(2, int(max_ratio * dimension))
      p = 1.0 / np.arange(1, max_mutations) ** 1.5
      p /= np.sum(p)
      u = self.random_state.choice(np.arange(1, max_mutations), p=p)
      return self.portfolio_discrete_mutation(
          parent, intensity=u, arity=arity
      )
  
file_path: nevergrad/nevergrad/optimization/mutations.py
imports: import numpy
  import nevergrad.common.typing
  from nevergrad.parametrization import discretization
  from .None import utils
label_desc: Use image node_id 4 for calling the Mutator obj's underlying member method code with example usage: obj.doubledoerr_discrete_mutation(parent, max_ratio, arity) and returns: self