original_docstring: 
      Computes the rate distortion function for the standard sum of
      squares distortion function and distribution given by independent
      samples from a list of Gaussians with the given variances.
      
docstring: Computes the rate distortion function for the standard sum of
  squares distortion function and distribution given by independent
  samples from a list of Gaussians with the given variances.
docstring_tokens: Computes the rate distortion function for the standard sum of squares distortion function and distribution given by independent samples from a list of Gaussians with the given variances .
code: def rate_dist_ind_Gaussians(D, variances):
      """
      Computes the rate distortion function for the standard sum of
      squares distortion function and distribution given by independent
      samples from a list of Gaussians with the given variances.
      """
      variances = np.sort(variances[variances > 1e-10])
      n = len(variances)
      cum_sum = 0
      for i in range(n):
          phi = cum_sum + (n-i)*variances[i]
          if D < phi:
              lmda = (D - cum_sum) / (n - i)
              break
          cum_sum += variances[i]
      else:
          lmda = np.inf
  
      Di = variances.copy()
      Di[Di > lmda] = lmda
      return 1/2 * np.log(variances / Di).sum()
code_tokens: def rate_dist_ind_Gaussians ( D , variances ) : variances = np . sort ( variances [ variances > 1e-10 ] ) n = len ( variances ) cum_sum = 0 for i in range ( n ) : phi = cum_sum + ( n - i ) * variances [ i ] if D < phi : lmda = ( D - cum_sum ) / ( n - i ) break cum_sum += variances [ i ] else : lmda = np . inf Di = variances . copy ( ) Di [ Di > lmda ] = lmda return 1 / 2 * np . log ( variances / Di ) . sum ( )
short_docstring: Computes the rate distortion function for the standard sum of
  squares distortion function and distribution given by independent
  samples from a list of Gaussians with the given variances.
short_docstring_tokens: Computes the rate distortion function for the standard sum of squares distortion function and distribution given by independent samples from a list of Gaussians with the given variances .
comment: """
      Computes the rate distortion function for the standard sum of
      squares distortion function and distribution given by independent
      samples from a list of Gaussians with the given variances.
      """