Returns a index of a specified probability, e.g. the string is "100:1:32:200:16:30".
If it returns 0 that probability is 100/(100+1+32+200+16+30)

@param conf Configures specified probability
@return The index of a specified probability
354494
public static int randomSegment(String conf) {
        String[] tmp = StringUtils.split(conf, ":");
        int[] probability = new int[tmp.length];
        for (int i = 0; i < probability.length; i++)
            probability[i] = Integer.parseInt(tmp[i].trim());

        return randomSegment(probability);
    }
1038412
public final int resolveConstantIndex(int constant)
    {
        int size = 0;
        int index = 0;
        constantReadLock.lock();
        try
        {
            size = getConstantPoolSize();
            index = getConstantIndex(constant);
        }
        finally
        {
            constantReadLock.unlock();
        }
        if (index != -1)
        {
            return index;
        }
        return addConstantInfo(new ConstantInteger(constant), size);
    }
982087
private static Integer getMinLevelIndex(String value) {
        Integer minLevelIndex = 0;
        if ("info".equalsIgnoreCase(value)) {
            minLevelIndex = 6;
        } else {
            Level minLevel = Level.parse(value.toUpperCase());
            for (int i = 0; i < TrLevelConstants.levels.length; i++) {
                if (minLevel.equals(TrLevelConstants.levels[i])) {
                    minLevelIndex = i;
                    break;
                }
            }
        }
        return minLevelIndex;
    }
156191
@Reference(title = "Fast and accurate computation of binomial probabilities", //
      authors = "C. Loader", booktitle = "", //
      url = "http://projects.scipy.org/scipy/raw-attachment/ticket/620/loader2000Fast.pdf", //
      bibkey = "web/Loader00")
  public static double pmf(double x, int n, double p) {
    // Invalid values
    if(x < 0 || x > n) {
      return 0.;
    }
    // Extreme probabilities
    if(p <= 0.) {
      return x == 0 ? 1. : 0.;
    }
    if(p >= 1.) {
      return x == n ? 1. : 0.;
    }
    final double q = 1 - p;
    // FIXME: check for x to be integer, return 0 otherwise?

    // Extreme values of x
    if(x == 0) {
      if(p < .1) {
        return FastMath.exp(-devianceTerm(n, n * q) - n * p);
      }
      else {
        return FastMath.exp(n * FastMath.log(q));
      }
    }
    if(x == n) {
      if(p > .9) {
        return FastMath.exp(-devianceTerm(n, n * p) - n * q);
      }
      else {
        return FastMath.exp(n * FastMath.log(p));
      }
    }
    final double lc = stirlingError(n) - stirlingError(x) - stirlingError(n - x) - devianceTerm(x, n * p) - devianceTerm(n - x, n * q);
    final double f = (MathUtil.TWOPI * x * (n - x)) / n;
    return FastMath.exp(lc) / FastMath.sqrt(f);
  }
618266
public String getString(int index)
  {
    Object value = _values[index - 1];

    if (value != null) {
      return value.toString();
    }
    else {
      return null;
    }
  }
527296
public static double inverfc(double p) {
        double x, err, t, pp;
        if (p >= 2.0) {
            return -100.;
        }
        if (p <= 0.0) {
            return 100.;
        }
        pp = (p < 1.0) ? p : 2. - p;
        t = Math.sqrt(-2. * Math.log(pp / 2.));
        x = -0.70711 * ((2.30753 + t * 0.27061) / (1. + t * (0.99229 + t * 0.04481)) - t);
        for (int j = 0; j < 2; j++) {
            err = erfc(x) - pp;
            x += err / (1.12837916709551257 * Math.exp(-x * x) - x * err);
        }
        return (p < 1.0 ? x : -x);
    }
701618
function toFreq (p, tuning) {
  if (NUM.test(p)) return +p
  var midi = toMidi(asPitch.parse(p))
  if (!midi) return null
  tuning = tuning || 440
  return Math.pow(2, (midi - 69) / 12) * tuning
}
1194857
@Override
    public int getIndex(String qName)
    {
        if (mElemStack == null) {
            return -1;
        }
        int ix = mElemStack.findAttributeIndex(null, qName);
        // !!! In ns-as-attrs mode, should also match ns decls?
        return ix;
    }
142683
public Counter<L> probabilityOf(Datum<L, F> example) {
    if(example instanceof RVFDatum<?, ?>)return probabilityOfRVFDatum((RVFDatum<L,F>)example);
    Counter<L> scores = logProbabilityOf(example);
    for (L label : scores.keySet()) {
      scores.setCount(label, Math.exp(scores.getCount(label)));
    }
    return scores;
  }
736120
public int indexOf( byte value ) {
		for (int i = 0; i < size; i++) {
			if( data[i] == value )
				return i;
		}
		return -1;
	}
32194
public int indexOf(DateTimeFieldType type) {
        for (int i = 0, isize = size(); i < isize; i++) {
            if (getFieldType(i) == type) {
                return i;
            }
        }
        return -1;
    }
1353546
public char setIndex(int pos) 
  { 
    if (pos < 0) {
      _pos = 0;
      return DONE;
    }
    else if (_length <= pos) {
      _pos = _length;
      return DONE;
    }
    else {
      _pos = pos; 
      return _string.charAt(pos);
    }
  }
643814
public int indexOf(T x) {
    int r=Arrays.binarySearch(data,x);
    return(r>=0?r:-1);
  }
978173
public final int getConstantIndex(float constant)
    {
        for (ConstantInfo ci : listConstantInfo(ConstantFloat.class))
        {
            ConstantFloat ic = (ConstantFloat) ci;
            if (Float.compare(constant, ic.getConstant()) == 0)
            {
                return constantPoolIndexMap.get(ci);
            }
        }
        return -1;
    }
82164
public final int getConstantIndex(double constant)
    {
        for (ConstantInfo ci : listConstantInfo(ConstantDouble.class))
        {
            ConstantDouble ic = (ConstantDouble) ci;
            if (Double.compare(constant, ic.getConstant()) == 0)
            {
                return constantPoolIndexMap.get(ci);
            }
        }
        return -1;
    }
810491
public static final String getString(int index) {
    	if (index < 1) throw new NumberFormatException(
    			"You can't translate a negative number into an alphabetical value.");
    	
    	index--;
    	int bytes = 1;
    	int start = 0;
    	int symbols = 26;  
    	while(index >= symbols + start) {
    		bytes++;
    	    start += symbols;
    		symbols *= 26;
    	}
    	      
    	int c = index - start;
    	char[] value = new char[bytes];
    	while(bytes > 0) {
    		value[--bytes] = (char)( 'a' + (c % 26));
    		c /= 26;
    	}
    	
    	return new String(value);
	}
1039886
public static int indexOf(ByteBuf buffer, int fromIndex, int toIndex, byte value) {
        if (fromIndex <= toIndex) {
            return firstIndexOf(buffer, fromIndex, toIndex, value);
        } else {
            return lastIndexOf(buffer, fromIndex, toIndex, value);
        }
    }