import java.util.*;
import java.lang.Math.*;
class geometric{
public static void main(String[] args){
Random rand = new Random();
for (int i=0; i<100; i++){
double seed = rand.nextDouble();
double prob=0.2654;
long geo = (long)Math.ceil(Math.log((double)seed)/Math.log(1.0-prob));
System.out.println(geo);}
}
}
I use this code to generate random geometric numbers. The problem is that the resulting numbers don't fit into a certain range. My question is this: how to scale the numbers into a range from 1 to 100 for example or from 0 to 1. A simple solution like finding the bigger number and dividing all the others with it won't work because I need to produce one number at a time and not all 100 at the same time.
I am really desperate so any help will be extremely appreciated.
Thanks in advance.