code: def _truncnorm_sf(truncation_level, values):
      
      # notation from http://en.wikipedia.org/wiki/Truncated_normal_distribution.
      # given that mu = 0 and sigma = 1, we have alpha = a and beta = b.
  
      # "CDF" in comments refers to cumulative distribution function
      # of non-truncated distribution with that mu and sigma values.
  
      # assume symmetric truncation, that is ``a = - truncation_level``
      # and ``b = + truncation_level``.
  
      # calculate CDF of b
      phi_b = ndtr(truncation_level)
  
      # calculate Z as ``Z = CDF(b) - CDF(a)``, here we assume that
      # ``CDF(a) == CDF(- truncation_level) == 1 - CDF(b)``
      z = phi_b * 2 - 1
  
      # calculate the result of survival function of ``values``,
      # and restrict it to the interval where probability is defined --
      # 0..1. here we use some transformations of the original formula
      # that is ``SF(x) = 1 - (CDF(x) - CDF(a)) / Z`` in order to minimize
      # number of arithmetic operations and function calls:
      # ``SF(x) = (Z - CDF(x) + CDF(a)) / Z``,
      # ``SF(x) = (CDF(b) - CDF(a) - CDF(x) + CDF(a)) / Z``,
      # ``SF(x) = (CDF(b) - CDF(x)) / Z``.
      return ((phi_b - ndtr(values)) / z).clip(0.0, 1.0)
docs: Survival function for truncated normal distribution.
  
      Assumes zero mean, standard deviation equal to one and symmetric
      truncation.
  
      :param truncation_level:
          Positive float number representing the truncation on both sides
          around the mean, in units of sigma.
      :param values:
          Numpy array of values as input to a survival function for the given
          distribution.
      :returns:
          Numpy array of survival function results in a range between 0 and 1.
  
      >>> from scipy.stats import truncnorm
      >>> truncnorm(-3, 3).sf(0.12345) == _truncnorm_sf(3, 0.12345)
      True