Package org.apache.mahout.math.list

Examples of org.apache.mahout.math.list.DoubleArrayList


      double v1 = entropy.get(trueValue, 1);
      entropy.set(trueValue, 1, (Math.log(limited) - v1) / samples + v1);
    }

    // add to buffers
    DoubleArrayList buf = scores[trueValue];
    if (buf.size() >= maxBufferSize) {
      // but if too many points are seen, we insert into a random
      // place and discard the predecessor.  The random place could
      // be anywhere, possibly not even in the buffer.
      // this is a special case of Knuth's permutation algorithm
      // but since we don't ever shuffle the first maxBufferSize
      // samples, the result isn't just a fair sample of the prefixes
      // of all permutations.  The CONTENTs of the result, however,
      // will be a fair and uniform sample of maxBufferSize elements
      // chosen from all elements without replacement
      int index = rand.nextInt(samples);
      if (index < buf.size()) {
        buf.set(index, score);
      }
    } else {
      // for small buffers, we collect all points without permuting
      // since we sort the data later, permuting now would just be
      // pedantic
      buf.add(score);
    }
  }
View Full Code Here


      double v1 = entropy.get(trueValue, 1);
      entropy.set(trueValue, 1, (Math.log(limited) - v1) / samples + v1);
    }

    // add to buffers
    DoubleArrayList buf = scores[trueValue];
    if (buf.size() >= maxBufferSize) {
      // but if too many points are seen, we insert into a random
      // place and discard the predecessor.  The random place could
      // be anywhere, possibly not even in the buffer.
      // this is a special case of Knuth's permutation algorithm
      // but since we don't ever shuffle the first maxBufferSize
      // samples, the result isn't just a fair sample of the prefixes
      // of all permutations.  The CONTENTs of the result, however,
      // will be a fair and uniform sample of maxBufferSize elements
      // chosen from all elements without replacement
      int index = rand.nextInt(samples);
      if (index < buf.size()) {
        buf.set(index, score);
      }
    } else {
      // for small buffers, we collect all points without permuting
      // since we sort the data later, permuting now would just be
      // pedantic
      buf.add(score);
    }
  }
View Full Code Here

    return values.size();
  }

  @Override
  public int getNumNonZeroElements() {
    DoubleArrayList elementValues = values.values();
    int numMappedElements = elementValues.size();
    int numNonZeros = 0;
    for (int index = 0; index < numMappedElements; index++) {
      if (elementValues.getQuick(index) != 0) {
        numNonZeros++;
      }
    }
    return numNonZeros;
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.list.DoubleArrayList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.