code: func calcFraction(lower, upper, value float64) float64 {
  	if upper <= lower {
  		return 0.5
  	}
  	if value <= lower {
  		return 0
  	}
  	if value >= upper {
  		return 1
  	}
  	frac := (value - lower) / (upper - lower)
  	if math.IsNaN(frac) || math.IsInf(frac, 0) || frac < 0 || frac > 1 {
  		return 0.5
  	}
  	return frac
  }
docs: // calcFraction is used to calculate the fraction of the interval [lower, upper] that lies within the [lower, value]
  // using the continuous-value assumption.