Question

I am generating weighted random numbers(sampling with replacement) through the following code

    Object[] population = { 0, 1 };
    double[] weights = { p1, p2 };
    Sampling randsamp = new Sampling(population, weights);
    X = (Integer) randsamp.next();

I have tried different values of p1 and p2 which are the probabilities and 0 and 1 are the population(numbers which are to be generated based on p1 and p2). However, running the code multiple times produces the same result, for example if I make 10 iterations and store the result in an array X[] I get the same array every time the code is executes. Can someone tell me why is this happening? Should I not get different array/numbers at each iteration?

Thanks

Was it helpful?

Solution

If you search in google jpsgcs.alun.random.Sampling, you get some broken links about this Sampling class. Moreover, if you browse here you can see that in the jar, that you can download, there is no more even such a package like random. So, probably that was removed for some reasons ... Maybe this Sampling class was removed because not working properly? I can just suggest you to get in touch with somebody that wrote this library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top