Get different number of the given number.

@param weight array contains weight of the nodes
@return number of different weight
198049
public int checkDiffNumber(double[] weight) {
        // Count the number of different weight
        double category[] = new double[weight.length];
        int i, j;
        int count = 1;
        double t;
        category[1] = weight[1];
        for (i = 2; i < weight.length; i++) {
            for (j = 1; j <= count; j++) {
                t = weight[i] - category[j];
                if (t < 0.0) t = -t;
                if (t < LOST) break;
            }
            if (j > count) {
                count += 1;
                category[count] = weight[i];
            }
        }
        return count;
    }
654396
public int weightOf(String suggestion) {
        Node n = getNode(suggestion);
        return (n != null) ? n.weight : -1;
    }
458980
@Override
  public double getWeight(double distance, double max, double stddev) {
    if(stddev <= 0) {
      return 1;
    }
    double normdistance = distance / stddev;
    return scaling * FastMath.exp(-.5 * normdistance * normdistance) / stddev;
  }
800062
def check_weights(nodes_with_a_weight):
    
    weights = [n['weight'] for n in nodes_with_a_weight]
    if abs(sum(weights) - 1.) > PRECISION:
        raise ValueError('The weights do not sum up to 1: %s' % weights)
    return nodes_with_a_weight
1128650
public static double spearman(int[] x, int[] y) {
        if (x.length != y.length)
            throw new IllegalArgumentException(String.format("Arrays have different length: x[%d], y[%d]", x.length, y.length));

        return 1 - Math.spearman(x, y);
    }
541443
@Override
    public double getMean() {
        if (values.length == 0) {
            return 0;
        }

        double sum = 0;
        for (int i = 0; i < values.length; i++) {
            sum += values[i] * normWeights[i];
        }
        return sum;
    }
401187
@Override
    public Long getMinimumFinish() {
        calculator();
        if (simple) {
            return v[2];
        } else {
            Weight minFinish = cn.getMinimumFinish();
            return minFinish.isInfinity() ? null : minFinish.value();
        }
    }
1224082
@Override
  public double getWeight(double distance, double max, double stddev) {
    if(max <= 0) {
      return 1.0;
    }
    double relativedistance = distance / max;
    return 1.0 - 0.9 * relativedistance * relativedistance;
  }
1342312
public Endpoint withWeight(int weight) {
        ensureSingle();
        validateWeight(weight);
        if (this.weight == weight) {
            return this;
        }
        return new Endpoint(host(), ipAddr(), port, weight, hostType);
    }
378605
public function getWeight()
    {
        $weight = 0;

        foreach ($this->_aBasketContents as $oBasketItem) {
            $weight += $oBasketItem->getWeight();
        }

        return $weight;
    }
1236871
public int[] getEquivalentClass(double[] weight) {
        double category[] = new double[weight.length];
        int equivalentClass[] = new int[weight.length];
        int i, j;
        int count = 1;
        double t;
        category[1] = weight[1];
        for (i = 2; i < weight.length; i++) {
            for (j = 1; j <= count; j++) {
                t = weight[i] - category[j];
                if (t < 0.0) {
                    t = -t;
                }
                if (t < LOST) {
                    break;
                }
            }
            if (j > count) {
                count += 1;
                category[count] = weight[i];
            }
        }

        for (i = 1; i < weight.length; i++) {
            for (j = 1; j <= count; j++) {
                t = weight[i] - category[j];
                if (t < 0.0) {
                    t = -t;
                }
                if (t < LOST) {
                    equivalentClass[i] = j;
                }
            }
        }
        equivalentClass[0] = count;
        return equivalentClass;
    }
56779
@Override
    public double[] getVotesForInstance(Instance inst) {

        if (m_weights == null) {
            return new double[inst.numAttributes() + 1];
        }

        double[] result = new double[2];

        double wx = dotProd(inst, m_weights, inst.classIndex());// * m_wScale;
        double z = (wx + m_weights[m_weights.length - 1]);
        //System.out.print("" + z + ": ");
        // System.out.println(1.0 / (1.0 + Math.exp(-z)));
        if (z <= 0) {
            //  z = 0;
            if (m_loss == LOGLOSS) {
                result[0] = 1.0 / (1.0 + Math.exp(z));
                result[1] = 1.0 - result[0];
            } else {
                result[0] = 1;
            }
        } else {
            if (m_loss == LOGLOSS) {
                result[1] = 1.0 / (1.0 + Math.exp(-z));
                result[0] = 1.0 - result[1];
            } else {
                result[1] = 1;
            }
        }
        return result;
    }
304814
public static List<Double> getWeights(ZParams params) {
		Collection<byte[]> collect = params.getParams();
		Iterator<byte[]> iterator = collect.iterator();
		boolean hasWeights = false;
		while (iterator.hasNext()) {
			String value = new String(iterator.next());
			// System.out.println("value:" + value);
			if ("weights".equals(value)) {
				hasWeights = true;
				break;
			}
		}
		if (!hasWeights) {
			return null;
		}
		List<Double> result = new ArrayList<Double>();
		while (iterator.hasNext()) {
			String weight = new String(iterator.next());
			result.add(Double.parseDouble(weight));
		}
		return result;
	}
112119
public double weight() {
        double result = 0;
        Iterator edgeIterator = edgeSet().iterator();
        while (edgeIterator.hasNext()) {
            result += ((Edge) edgeIterator.next()).getWeight();
        }
        return result;
    }
8828
def getWeight(grph, nd1, nd2, weightString = "weight", returnType = int):
    
    if not weightString:
        return returnType(1)
    else:
        return returnType(grph.edges[nd1, nd2][weightString])
1276164
public int[] findTopoEquivClass(double[] weight) {
        int trialCount, i;
        int equivalentClass[] = new int[weight.length];
        int count = checkDiffNumber(weight);
        trialCount = count;
        if (count == nodeNumber) {
            for (i = 1; i <= nodeNumber; i++) {
                equivalentClass[i] = i;
            }
            equivalentClass[0] = count;
            return equivalentClass;
        }
        do {
            count = trialCount;
            double[][] trialNodeMatrix = buildTrialNodeMatrix(weight);
            double[] trialWeight = buildWeightMatrix(trialNodeMatrix, bondMatrix);
            trialCount = checkDiffNumber(trialWeight);
            if (trialCount == nodeNumber) {
                for (i = 1; i <= nodeNumber; i++) {
                    equivalentClass[i] = i;
                }
                equivalentClass[0] = count;
                return equivalentClass;
            }
            if (trialCount <= count) {
                equivalentClass = getEquivalentClass(weight);
                return equivalentClass;
            }
        } while (trialCount > count);
        return equivalentClass;
    }
995081
public function setWeight($weight)
    {
        if ($weight !== NULL && !is_float($weight) && !is_int($weight)) {
            throw new InvalidArgumentException('Invalid weight given - must be numeric or NULL');
        }
        $this->weight = $weight;

        return $this;
    }