Ranks the data in inlist, dealing with ties appropritely.  Assumes
a 1D inlist.  Adapted from Gary Perlman's |Stat ranksort.

Usage:   rankdata(inlist)
Returns: a list of length equal to inlist, containing rank scores
179574
def rankdata(inlist):
    
    n = len(inlist)
    svec, ivec = shellsort(inlist)
    sumranks = 0
    dupcount = 0
    newlist = [0] * n
    for i in range(n):
        sumranks = sumranks + i
        dupcount = dupcount + 1
        if i == n - 1 or svec[i] != svec[i + 1]:
            averank = sumranks / float(dupcount) + 1
            for j in range(i - dupcount + 1, i + 1):
                newlist[ivec[j]] = averank
            sumranks = 0
            dupcount = 0
    return newlist
778430
def get_comparable_values_for_ordering(self):
        

        return (0 if self.position >= 0 else 1, int(self.position), str(self.name), str(self.description))
248360
public static double getValueForRank(int rank,double[] scores){
    double[] copy = new double[scores.length];
    System.arraycopy(scores,0,copy,0,scores.length);
    java.util.Arrays.sort(copy);
    rank = scores.length-rank;
    return copy[rank];
  }
851675
def ranked_attributes(self):
        
        matrix = javabridge.call(self.jobject, "rankedAttributes", "()[[D")
        if matrix is None:
            return None
        else:
            return arrays.double_matrix_to_ndarray(matrix)
397634
int createList(int listData) {
		int list = newList_();
		// m_lists.set_field(list, 0, null_node());//head
		// m_lists.set_field(list, 1, null_node());//tail
		// m_lists.set_field(list, 2, null_node());//prev list
		m_lists.setField(list, 3, m_list_of_lists); // next list
		m_lists.setField(list, 4, 0);// node count in the list
		m_lists.setField(list, 5, listData);
		if (m_list_of_lists != nullNode())
			setPrevList_(m_list_of_lists, list);

		m_list_of_lists = list;
		return list;
	}
1334049
public static Statistics statisticsOf(List<Statistics> data) {
        if (data.isEmpty())
            return null;
        
        Iterator<Statistics> iterator = data.iterator();
        if (!iterator.hasNext()) {
            return null;
        }
        Statistics first = null;
        while (first == null && iterator.hasNext()) {
            first = iterator.next();
        }
        if (first == null)
            return null;
        
        int count = first.getCount();
        double min = first.getMinimum().doubleValue();
        double max = first.getMaximum().doubleValue();
        double total = first.getAverage() * first.getCount();
        double totalSquare = (first.getStdDev() * first.getStdDev() + first.getAverage() * first.getAverage()) * first.getCount();
        
        while (iterator.hasNext()) {
            Statistics stats = iterator.next();
            if (stats.getMaximum().doubleValue() > max)
                max = stats.getMaximum().doubleValue();
            if (stats.getMinimum().doubleValue() < min)
                min = stats.getMinimum().doubleValue();
            total += stats.getAverage() * stats.getCount();
            totalSquare += ( stats.getStdDev() * stats.getStdDev() + stats.getAverage() * stats.getAverage() ) * stats.getCount();
            count += stats.getCount();
        }
        
        double average = total/count;
        double stdDev = Math.sqrt(totalSquare / count - average * average);
        
        return new StatisticsImpl(count, min, max, average, stdDev);
    }
537232
def is_sorted(self, ranks=None):
        
        ranks = ranks or self.ranks

        return check_sorted(self, ranks)
988582
def rank_remove(self, rank, items, cutoff):

        

        def remove(tokens):
            return [t for t in tokens if t not in to_remove]

        if rank == "df":
            to_remove = set([t[0] for t in self.df_ranking if t[1] <= cutoff])
        elif rank == "tfidf":
            to_remove = set([t[0] for t in self.tfidf_ranking
                             if t[1] <= cutoff])
        else:
            raise ValueError("Rank must be either \'df\' or \'tfidf\'.")

        if items == 'tokens':
            self.tokens = list(map(remove, self.tokens))
        elif items == 'bigrams':
            self.bigrams = list(map(remove, self.bigrams))
        elif items == 'stems':
            self.stems = list(map(remove, self.stems))
        else:
            raise ValueError("Items must be either \'tokens\', \'bigrams\' or \'stems\'.")
1227974
def select_highest_ranked (elements, ranks):
    
    assert is_iterable(elements)
    assert is_iterable(ranks)
    if not elements:
        return []

    max_rank = max_element (ranks)

    result = []
    while elements:
        if ranks [0] == max_rank:
            result.append (elements [0])

        elements = elements [1:]
        ranks = ranks [1:]

    return result
8254
public double[] toWraparoundOrder(double data[]){
    double newdata[] = new double[2*n];
    int nh = n/2;
    newdata[0]   = data[0];
    newdata[1]   = 0.0;
    newdata[n]   = data[1];
    newdata[n+1] = 0.0;
    for(int i=1; i<nh; i++){
      newdata[2*i]      = data[2*i];
      newdata[2*i+1]    = data[2*i+1];
      newdata[2*(n-i)]  = data[2*i];
      newdata[2*(n-i)+1]=-data[2*i+1]; }
    return newdata; }
274693
def medianscore(inlist):
    

    newlist = copy.deepcopy(inlist)
    newlist.sort()
    if len(newlist) % 2 == 0:   # if even number of scores, average middle 2
        index = len(newlist) / 2  # integer division correct
        median = float(newlist[index] + newlist[index - 1]) / 2
    else:
        index = len(newlist) / 2  # int divsion gives mid value when count from 0
        median = newlist[index]
    return median
822092
def describe(inlist):
    
    n = len(inlist)
    mm = (min(inlist), max(inlist))
    m = mean(inlist)
    sd = stdev(inlist)
    sk = skew(inlist)
    kurt = kurtosis(inlist)
    return n, mm, m, sd, sk, kurt
779994
public int rank() {
        if (!full) {
            throw new IllegalStateException("This is not a FULL singular value decomposition.");
        }

        int r = 0;
        for (int i = 0; i < s.length; i++) {
            if (s[i] > tol) {
                r++;
            }
        }
        return r;
    }
849074
def get_dimension(data):
    
    result = [0, 0]

    if isinstance(data, list):
        result = get_dimension_array(data)

    elif isinstance(data, dict):
        result = get_dimension_dict(data)

    return result
822538
private void rankArrayList(List<InvPair> v) {
        int num = 1;
        int[] temp = new int[v.size()];
        InvPair last = (InvPair) v.get(0);
        Iterator<InvPair> it = v.iterator();
        InvPair curr;
        for (int x = 0; it.hasNext(); x++) {
            curr = (InvPair) it.next();
            if (!last.equals(curr)) {
                num++;
            }
            temp[x] = num;
            last = curr;
        }
        it = v.iterator();
        for (int x = 0; it.hasNext(); x++) {
            curr = (InvPair) it.next();
            curr.setCurr(temp[x]);
            curr.setPrime();
        }
    }
602274
def ranked_attributes(self):
        
        matrix = javabridge.call(self.jobject, "rankedAttributes", "()[[D")
        if matrix is None:
            return None
        else:
            return typeconv.double_matrix_to_ndarray(matrix)
1103482
def ToDeltas(self):
    
    if len(self.data) < 2:
      self.data = []
      return
    for i in range(0, len(self.data) - 1):
      if self.data[i][0] is None or self.data[i + 1][0] is None:
        self.data[i][0] = None
      else:
        self.data[i][0] = self.data[i + 1][0] - self.data[i][0]
    del self.data[-1]