Example usage for org.apache.mahout.clustering UncommonDistributions rNorm

List of usage examples for org.apache.mahout.clustering UncommonDistributions rNorm

Introduction

In this page you can find the example usage for org.apache.mahout.clustering UncommonDistributions rNorm.

Prototype

public static double rNorm(double mean, double sd) 

Source Link

Document

Return a random value from a normal distribution with the given mean and standard deviation

Usage

From source file:DisplayClustering.java

License:Apache License

/**
 * Generate random samples and add them to the sampleData
 *
 * @param num/*from  w  w w.ja  v a 2 s.  c  om*/
 *          int number of samples to generate
 * @param mx
 *          double x-value of the sample mean
 * @param my
 *          double y-value of the sample mean
 * @param sd
 *          double standard deviation of the samples
 */
protected static void generateSamples(int num, double mx, double my, double sd) {
    double[] params = { mx, my, sd, sd };
    SAMPLE_PARAMS.add(new DenseVector(params));
    log.info("Generating {} samples m=[{}, {}] sd={}", num, mx, my, sd);
    for (int i = 0; i < num; i++) {
        SAMPLE_DATA.add(new VectorWritable(new DenseVector(
                new double[] { UncommonDistributions.rNorm(mx, sd), UncommonDistributions.rNorm(my, sd) })));
    }
}

From source file:DisplayClustering.java

License:Apache License

/**
 * Generate random samples and add them to the sampleData
 *
 * @param num// www .j  a v a 2 s. c  o m
 *          int number of samples to generate
 * @param mx
 *          double x-value of the sample mean
 * @param my
 *          double y-value of the sample mean
 * @param sdx
 *          double x-value standard deviation of the samples
 * @param sdy
 *          double y-value standard deviation of the samples
 */
protected static void generate2dSamples(int num, double mx, double my, double sdx, double sdy) {
    double[] params = { mx, my, sdx, sdy };
    SAMPLE_PARAMS.add(new DenseVector(params));
    log.info("Generating {} samples m=[{}, {}] sd=[{}, {}]", num, mx, my, sdx, sdy);
    for (int i = 0; i < num; i++) {
        SAMPLE_DATA.add(new VectorWritable(new DenseVector(
                new double[] { UncommonDistributions.rNorm(mx, sdx), UncommonDistributions.rNorm(my, sdy) })));
    }
}