class_docstr: @brief Genetic algorithm math API.
docstr: !
          
code: def calc_probability_vector(fitness):
      """!"""
  
      if len(fitness) == 0:
          raise AttributeError("Fitness functions are empty.")
  
      # Get 1/fitness function
      inv_fitness = np.zeros(len(fitness))
  
      #
      for _idx in range(len(inv_fitness)):
          fitness_value = fitness[_idx]
          if fitness_value != 0.0:
              if np.isinf(fitness_value):
                  raise ValueError(
                      "Impossible to calculate the probability of getting reproduced. "
                      "Make sure that input data for clustering is normalized between [0, 1]."
                  )
  
              inv_fitness[_idx] = 1.0 / fitness_value
          else:
              inv_fitness[_idx] = 0.0
  
      # Initialize vector
      prob = np.zeros(len(fitness))
  
      # Initialize first element
      prob[0] = inv_fitness[0]
  
      # Accumulate values in probability vector
      for _idx in range(1, len(inv_fitness)):
          prob[_idx] = prob[_idx - 1] + inv_fitness[_idx]
  
      # Normalize
      prob /= prob[-1]
  
      ga_math.set_last_value_to_one(prob)
  
      return prob
  
file_path: pyclustering/pyclustering/cluster/ga_maths.py
imports: import numpy
label_desc: Use image node_id 5 for calling the ga_math obj's underlying member method code with example usage: obj.calc_probability_vector(fitness) and returns: prob