Package org.apache.mahout.math.function

Examples of org.apache.mahout.math.function.DoubleFunction


  @Test
  public void testGivensQR() throws Exception {
    // DenseMatrix m = new DenseMatrix(dims<<2,dims);
    Matrix m = new DenseMatrix(3, 3);
    m.assign(new DoubleFunction() {
      private final Random rnd = RandomUtils.getRandom();
      @Override
      public double apply(double arg0) {
        return rnd.nextDouble() * SCALE;
      }
View Full Code Here


    final Random rand = RandomUtils.getRandom();

    // build a vector full of sample from exponential distribuiton
    // this will have lots of little positive values and a few big ones
    Vector p1 = new DenseVector(25)
      .assign(new DoubleFunction() {
        @Override
        public double apply(double arg1) {
          return -Math.log(1 - rand.nextDouble());
        }
      });
View Full Code Here

          private final Random random = RandomUtils.getRandom();
          @Override
          public Vector apply(Integer dummy) {
            Vector result =
                type == VectorType.SPARSE ? new RandomAccessSparseVector(numItems) : new DenseVector(numItems);
            result.assign(new DoubleFunction(){
              @Override
              public double apply(double ignored) {
                return random.nextDouble();
              }
            });
View Full Code Here

        }
    }

    @Test
    public void testTraining() throws IOException {
        DoubleFunction randomValue = new DoubleFunction() {
            private Random gen = new Random(1);

            public double apply(double arg1) {
                return gen.nextGaussian();
            }
View Full Code Here

    final Matrix materializedOmega = new DenseMatrix(n, kp);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < kp; j++)
        materializedOmega.setQuick(i, j, omega.getQuick(i, j));
    Vector xi = new DenseVector(n);
    xi.assign(new DoubleFunction() {
      @Override
      public double apply(double x) {
        return rnd.nextDouble() * 100;
      }
    });
View Full Code Here

   * @param projectedVectorSize final projected size of a vector (number of projection vectors)
   * @param vectorSize initial vector size
   * @return a list of projection vectors
   */
  public static List<Vector> generateVectorBasis(int projectedVectorSize, int vectorSize) {
    DoubleFunction random = new Normal();
    List<Vector> basisVectors = Lists.newArrayList();
    for (int i = 0; i < projectedVectorSize; ++i) {
      Vector basisVector = new DenseVector(vectorSize);
      basisVector.assign(random);
      basisVector.normalize();
View Full Code Here

    }
  }

  private static Vector randomVector(final Random gen, int n) {
    Vector x = new DenseVector(n);
    x.assign(new DoubleFunction() {
      @Override
      public double apply(double v) {
        return gen.nextGaussian();
      }
    });
View Full Code Here

      public double apply(Vector column) {
        return column.minValue();
      }
    }).minValue();

    source.assign(new DoubleFunction() {
      @Override
      public double apply(double value) {
        return (value - min) * range / (max - min);
      }
    });
View Full Code Here

   * Uniform [0,1) matrix generator function
   *
   * @param seed generator seed
   */
  public static final IntIntFunction uniformGenerator(final int seed) {
    return Functions.chain(new DoubleFunction() {
      @Override
      public double apply(double x) {
        return (x + 1.0) / 2.0;
      }
    }, uniformSymmetricGenerator(seed));
View Full Code Here

      // size of previous layer
      int row = isFinalLayer ? actualSize : actualSize - 1;
      Matrix weightMatrix = new DenseMatrix(row, sizePrevLayer);
      // initialize weights
      final RandomWrapper rnd = RandomUtils.getRandom();
      weightMatrix.assign(new DoubleFunction() {
        @Override
        public double apply(double value) {
          return rnd.nextDouble() - 0.5;
        }
      });
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.function.DoubleFunction

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.