All Downloads are FREE. Search and download functionalities are using the official Maven repository.

z11.M_ath Maven / Gradle / Ivy

There is a newer version: 1.8
Show newest version
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package z11;

import java.util.Random;

/**
 *
 * @author vietduc
 */
public class M_ath {

    private static Random rn = null;

    public static boolean hit(double d) {
        return Math.random() < d;
    }

    public static int getrd(int arg) {
        return (int) (Math.random() * arg);
    }

    public static int getrd() {
        return getrd(1000000);
    }

    public static int getrd10() {
        return getrd() % 10;
    }
    
    public static String getrd10s() {
        return String.valueOf(getrd10());
    }
    public static double genNextGaussian(double mean, double standard_deviation) {
        if (rn == null) {
            rn = new Random();
        }
        return rn.nextGaussian() * standard_deviation + mean;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            z11.L_ogger.print("" + M_ath.genNextGaussian(100, 1));
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy