Creates a Distribution from the given counter, ie makes an internal
copy of the counter and divides all counts by the total count.

@return a new Distribution
171541
public static <E> Distribution<E> getDistributionFromLogValues(Counter<E> counter) {
    ClassicCounter<E> c = new ClassicCounter<E>();
    // go through once to get the max
    // shift all by max so as to minimize the possibility of underflow
    double max = Counters.max(counter); // Thang 17Feb12: max should operate on counter instead of c, fixed!
    for (E key : counter.keySet()) {
      double count = Math.exp(counter.getCount(key) - max);
      c.setCount(key, count);
    }
    return getDistribution(c);
  }
532922
public T divide(T divisor) {
        if (divisor == null) {
            throw new IllegalArgumentException("invalid (null) divisor");
        }
        BigDecimal quotient = this.value.divide(divisor.value, ROUND_BEHAVIOR);

        return newInstance(quotient, this.value.scale());
    }
964480
public Binder spread(int count) {
        if (count == 0) {
            return dropLast();
        }

        Class<?> aryType = type().parameterType(type().parameterCount() - 1);

        assert aryType.isArray();

        Class<?>[] spreadTypes = new Class[count];
        Arrays.fill(spreadTypes, aryType.getComponentType());

        return spread(spreadTypes);
    }
1209227
public DistributerMap createMap() {
    final DistributerMap map = new DistributerMap();
    map.setProject(getProject());
    this.maps.addElement(map);
    return map;
  }
371762
public Binder spread(Class<?>... spreadTypes) {
        if (spreadTypes.length == 0) {
            return dropLast();
        }

        return new Binder(this, new Spread(type(), spreadTypes));
    }
1183779
protected final PrcCsvColumnCreate<RS>
    createPutPrcCsvColumnCreate() throws Exception {
    PrcCsvColumnCreate<RS> proc = new PrcCsvColumnCreate<RS>();
    @SuppressWarnings("unchecked")
    PrcEntityCreate<RS, CsvColumn, Long> procDlg =
      (PrcEntityCreate<RS, CsvColumn, Long>)
        lazyGet(null, PrcEntityCreate.class.getSimpleName());
    proc.setPrcEntityCreate(procDlg);
    //assigning fully initialized object:
    this.processorsMap
      .put(PrcCsvColumnCreate.class.getSimpleName(), proc);
    return proc;
  }
213153
public Counter<K1> sumInnerCounter() {
    Counter<K1> summed = new ClassicCounter<K1>();
    for (K1 key : this.firstKeySet()) {
      summed.incrementCount(key, this.getCounter(key).totalCount());
    }
    return summed;
  }
240826
public static <I, O> Example<I, O> create(I input, O output) {
    return new Example<I, O>(input, output);
  }
748712
public synchronized SamplerResult<T> finishSampling(int count)
    {
        List<Counter<T>> results = Collections.EMPTY_LIST;
        long cardinality = 0;
        if (enabled)
        {
            enabled = false;
            results = summary.topK(count);
            cardinality = hll.cardinality();
        }
        return new SamplerResult<T>(results, cardinality);
    }
762607
public static TaxNumberMapSharedConstants create() {
    if (taxNumberMapConstants == null) { // NOPMD it's thread save!
      synchronized (TaxNumberMapConstantsImpl.class) {
        if (taxNumberMapConstants == null) {
          taxNumberMapConstants = new TaxNumberMapConstantsImpl(
              readMapFromProperties("TaxNumberMapConstants", "taxNumbers"));
        }
      }
    }
    return taxNumberMapConstants;
  }
1029412
public <K extends Serializable & Comparable> Process<K> newProcess()
    {
        final String queueOwner = partition == null ? null : partition.getQueueOwnerKey();
        Callback<ProcessWrapper<K>> callback = new Callback<ProcessWrapper<K>>() {

            @Override
            protected void doAction() {

                ProcessWrapper<K> process = ProcessWrapper.getNewInstance(
                        queueOwner, is_persistent, implementation_options);

                ProcessPersistence<ProcessEntity<K>,K> processHome = 
                        process.setDetails(process_name, queue, process_description, user,
                                           occurrence, visibility, access, resilience, output,
                                           pre_processes, post_processes, keep_completed,
                                           process_listeners, locale, implementation_options);

                if (report_type != null)
                    process.setReportType(report_type);

                if(source_name != null)
                    process.setSourceName(source_name);

                setupProcess(new Process(process));

                preSubmitBatchJobProcessing();

                if (is_persistent) processHome.persist();

                process.getContainingServer().submitProcess(process);

                _return(process);
            }
        };

        QueujTransaction<K> transaction = (QueujTransaction<K>)QueujFactory.getTransaction();
        return new Process<K>(transaction.doTransaction(queueOwner, is_persistent, callback, true));
    }
698421
public static CounterValue newCounterValue(long value, long lowerBound, long upperBound) {
      return new CounterValue(value, calculateState(value, lowerBound, upperBound));
   }
1346354
@Override protected Split ltSplit(int col, Data d, int[] dist, int distWeight, Random rand) {
    final int[] distL = new int[d.classes()], distR = dist.clone();
    final double upperBoundReduction = upperBoundReduction(d.classes());
    double maxReduction = -1;
    int bestSplit = -1;
    int totL = 0, totR = 0;     // Totals in the distribution
    int classL = 0, classR = 0; // Count of non-zero classes in the left/right distributions
    for (int e: distR) { // All zeros for the left, but need to compute for the right
      totR += e;
      if( e != 0 ) classR++;
    }
    // For this one column, look at all his split points and find the one with the best gain.
    for (int i = 0; i < _columnDists[col].length - 1; ++i) {
      int [] cdis = _columnDists[col][i];
      for (int j = 0; j < distL.length; ++j) {
        int v = cdis[j];
        if( v == 0 ) continue;              // No rows with this class
        totL     += v;  totR     -= v;
        if( distL[j]== 0 ) classL++; // One-time transit from zero to non-zero for class j
        distL[j] += v;  distR[j] -= v;
        if( distR[j]== 0 ) classR--; // One-time transit from non-zero to zero for class j
      }
      if (totL == 0) continue;  // Totals are zero ==> this will not actually split anything
      if (totR == 0) continue;  // Totals are zero ==> this will not actually split anything

      // Compute gain.
      // If the distribution has only 1 class, the gain will be zero.
      double eL = 0, eR = 0;
      if( classL > 1 ) for (int e: distL) eL += gain(e,totL);
      if( classR > 1 ) for (int e: distR) eR += gain(e,totR);
      double eReduction = upperBoundReduction - ( (eL * totL + eR * totR) / (totL + totR) );

      if (eReduction == maxReduction) {
        // For now, don't break ties.  Most ties are because we have several
        // splits with NO GAIN.  This happens *billions* of times in a standard
        // covtype RF, because we have >100K leaves per tree (and 50 trees and
        // 54 columns per leave and however many bins per column), and most
        // leaves have no gain at most split points.
        //if (rand.nextInt(10)<2) bestSplit=i;
      } else if (eReduction > maxReduction) {
        bestSplit = i;  maxReduction = eReduction;
      }
    }
    return bestSplit == -1
            ? Split.impossible(Utils.maxIndex(dist,_random))
            : Split.split(col,bestSplit,maxReduction);
  }
607784
function distributeNthRoot(node) {
  let newNode = clone(node);
  const radicandNode = getRadicandNode(node);
  const rootNode = getRootNode(node);

  const children = [];
  for (let i = 0; i < radicandNode.args.length; i++) {
    const child = radicandNode.args[i];
    children.push(Node.Creator.nthRoot(child, rootNode));
  }

  newNode = Node.Creator.operator('*', children);
  return Node.Status.nodeChanged(
    ChangeTypes.DISTRIBUTE_NTH_ROOT, node, newNode);
}
1336809
def distribution(self, limit=1024):
        
        res = self._qexec("%s, count(*) as __cnt" % self.name(), group="%s" % self.name(),
                          order="__cnt DESC LIMIT %d" % limit)
        dist = []
        cnt = self._table.size()
        for i, r in enumerate(res):
            dist.append(list(r) + [i, r[1] / float(cnt)])

        self._distribution = pd.DataFrame(dist, columns=["value", "cnt", "r", "fraction"])
        self._distribution.index = self._distribution.r

        return self._distribution
1042533
public ByteBuffer createLocal(long count)
    {
        ContextState state = ContextState.allocate(0, 1, 0);
        state.writeLocal(CounterId.getLocalId(), 1L, count);
        return state.context;
    }
834406
@Override
	public CommerceOrderItem create(long commerceOrderItemId) {
		CommerceOrderItem commerceOrderItem = new CommerceOrderItemImpl();

		commerceOrderItem.setNew(true);
		commerceOrderItem.setPrimaryKey(commerceOrderItemId);

		commerceOrderItem.setCompanyId(companyProvider.getCompanyId());

		return commerceOrderItem;
	}