Generate random number in evaluation score

I have a reviewer r(i) has evaluated an object o(j), which is weighted with the assigned evaluation score e(i,j) ε[0,1]. The number of reviewers and objects are 10 each. My question is how to generate a random number with the fix number of reviewers per object at n=3. I mean each object should have evaluated only 3 reviewers.

I am able to generate a random number with the following:

Code:

`Random rand=new Random(); `

for(i=0; i<10; i++ ){

for(j=0; j<10; j++){

e[i][j]= rand.nextDouble();

System.out.println("e[" + i + "][" + j + "] = " +e[i][j]);

}

}

Could you advince how to solve my problem?

Thanks in advance!

Re: Generate random number in evaluation score

few questions.

1. what is the use of the random number?? is it the score given by a evaluator??

2. what is the significance of the term ε[0,1] mentioned in your post??

Re: Generate random number in evaluation score

Quote:

Originally Posted by

**skynet357** few questions.

1. what is the use of the random number?? is it the score given by a evaluator??

2. what is the significance of the term ε[0,1] mentioned in your post??

1.Yes, it is the score given by evaluator. Frist, i want to random evaluator to the object, each object should have evaluated by 3 evaluator and then random the score to the object. Can u give me an idea?

2. it's mean random sscore between 0 and 1.

Re: Generate random number in evaluation score

step to get 3 random evaluators

-------------------------------------------------

1. im assuming that your evaluators are indexed from 0 to 9.

2. using Math.random() method you can get a random double number 0<= e(0,1) >1.0 . multiply e(0,1) with 10 and use ceiling method to get random number between 0-9.

3. Use the above step in a loop to get 3 such random number aka three random evaluators for each object.

4. Getting random score shouldnt be a prob i guess. use any technique u want.

hope it helps :) .. if i mentioned something wrong then please revert back.

Re: Generate random number in evaluation score

From you case, you should use the Math.random() to get the result in the range of 0<randomValue<1.

Good luck.

Re: Generate random number in evaluation score

Quote:

Originally Posted by

**waiheng1986** you should use the Math.random()

That was already said, so there was no point in repeating it -- unless maybe you were just looking for a chance to promote your blog. And, both times round, it's **poor** advice since the OP is already using the preferred java.util.Random.

Quote:

Originally Posted by

**waiheng1986** ... or you can PM me~

Why? This is a **forum**, not a social networking site. Let's keep the discussions in the thread.

Your blog is hopelessly outdated, by the way. Did you copy random (no pun intended) content from older sites or did you have a teacher who doesn't bother to update their knowledge and thinking?

db

Re: Generate random number in evaluation score

Quote:

Originally Posted by

**skynet357** step to get 3 random evaluators

-------------------------------------------------

1. im assuming that your evaluators are indexed from 0 to 9.

2. using Math.random() method you can get a random double number 0<= e(0,1) >1.0 . multiply e(0,1) with 10 and use ceiling method to get random number between 0-9.

3. Use the above step in a loop to get 3 such random number aka three random evaluators for each object.

4. Getting random score shouldnt be a prob i guess. use any technique u want.

hope it helps :) .. if i mentioned something wrong then please revert back.

Thanks for your all reply. if i understand true your sleps and waiheng1986 are the same right? but i think it's different with my case. At my code above i was replaced i and j =4 instead of 10 because it's more short to show the output below:

e[0][0] = 0.5209047579028665

e[0][1] = 0.16964228925556757

e[0][2] = 0.017109708977610216

e[0][3] = 0.4459449995595135

e[1][0] = 0.48018250929274686

e[1][1] = 0.1467566990111293

e[1][2] = 0.6720265277818704

e[1][3] = 0.9081362342452916

e[2][0] = 0.5131552598409154

e[2][1] = 0.8759352295813813

e[2][2] = 0.4127244146368775

e[2][3] = 0.9190490419751117

e[3][0] = 0.7445842897466164

e[3][1] = 0.3305389644509955

e[3][2] = 0.5937900429674227

e[3][3] = 0.14275120308753864

but the putput that i want it's like:

e[0][0] = 0.5209047579028665

e[0][1] = 0.16964228925556757

e[0][3] = 0.4459449995595135

e[1][1] = 0.1467566990111293

e[1][2] = 0.6720265277818704

e[1][3] = 0.9081362342452916

e[2][0] = 0.5131552598409154

e[2][2] = 0.4127244146368775

e[2][3] = 0.9190490419751117

e[3][0] = 0.7445842897466164

e[3][1] = 0.3305389644509955

e[3][2] = 0.14275120308753864

It's mean i want to take a counter of row =3.

Re: Generate random number in evaluation score

Quote:

Originally Posted by

**Tianma** Thanks for your all reply. if i understand true your sleps and waiheng1986 are the same right? but i think it's different with my case.

Yes. Both those members appear to have not understood where your problem lies, and are trying to advise you about a different way to obtain a randim number. The second responder also appears to be trying to use this forum to promote its crappy blog, applying the logic that if the only tool you have is a hammer, treat everything as a nail.

You don't need that. Your approach to generating random numbers is just fine.

Quote:

Originally Posted by

**Tianma** It's mean i want to take a counter of row =3.

Not clear. Nor is your original problem description adequately clear.

For assigning three random reviewers out of a total of n reviewers to each of a total of m objects, I would create a Collection of n reviewers, iterate over a Collection of m objects, each time shuffling the reviewer collection and assigning the top three to the currently iterated object.

Read about the Collections API in this tutorial Trail: Collections (The Java™ Tutorials)

db

Re: Generate random number in evaluation score

Quote:

Originally Posted by

**DarrylBurke** Yes. Both those members appear to have not understood where your problem lies, and are trying to advise you about a different way to obtain a randim number. The second responder also appears to be trying to use this forum to promote its crappy blog, applying the logic that if the only tool you have is a hammer, treat everything as a nail.

You don't need that. Your approach to generating random numbers is just fine.

Not clear. Nor is your original problem description adequately clear.

For assigning three random reviewers out of a total of n reviewers to each of a total of m objects, I would create a Collection of n reviewers, iterate over a Collection of m objects, each time shuffling the reviewer collection and assigning the top three to the currently iterated object.

Read about the Collections API in this tutorial

Trail: Collections (The Java™ Tutorials)
db

Thanks so much sir. i'll try.

Re: Generate random number in evaluation score

Quote:

For assigning three random reviewers out of a total of n reviewers to each of a total of m objects, I would create a Collection of n reviewers, iterate over a Collection of m objects, each time shuffling the reviewer collection and assigning the top three to the currently iterated object.

Read about the Collections API in this tutorial

Trail: Collections (The Java™ Tutorials)
db

Hello, sir. When i read the collection, i'm confuse what i should do in my case, i should make a list,set or arraylist.Can you give me an example?