Results 1 to 10 of 10
 03092012, 08:46 AM #1Member
 Join Date
 Mar 2012
 Posts
 5
 Rep Power
 0
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:
Java 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]); } }
Thanks in advance!
 03092012, 04:10 PM #2Member
 Join Date
 Mar 2012
 Location
 Hyderabad, India
 Posts
 8
 Rep Power
 0
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??
 03092012, 04:16 PM #3Member
 Join Date
 Mar 2012
 Posts
 5
 Rep Power
 0
Re: Generate random number in evaluation score
Last edited by Tianma; 03092012 at 04:20 PM.
 03112012, 08:40 PM #4Member
 Join Date
 Mar 2012
 Location
 Hyderabad, India
 Posts
 8
 Rep Power
 0
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 09.
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.
 03122012, 07:15 AM #5Member
 Join Date
 Mar 2012
 Posts
 6
 Rep Power
 0
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.Last edited by waiheng1986; 03122012 at 11:54 AM.
 03122012, 10:41 AM #6
Re: Generate random number in evaluation score
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.
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?
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
 03122012, 11:09 AM #7Member
 Join Date
 Mar 2012
 Posts
 5
 Rep Power
 0
Re: Generate random number in evaluation score
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.Last edited by Tianma; 03122012 at 11:39 AM.
 03122012, 11:31 AM #8
Re: Generate random number in evaluation score
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)
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
 03122012, 12:17 PM #9Member
 Join Date
 Mar 2012
 Posts
 5
 Rep Power
 0
 03122012, 04:00 PM #10Member
 Join Date
 Mar 2012
 Posts
 5
 Rep Power
 0
Re: Generate random number in evaluation score
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
Similar Threads

Generate Random Number Loop
By saber210 in forum New To JavaReplies: 9Last Post: 08122011, 05:49 PM 
Can I get random.util not to generate the same number twice
By lilleza87 in forum New To JavaReplies: 3Last Post: 10242010, 11:24 PM 
Trying to Generate Random number
By PeterFeng in forum New To JavaReplies: 10Last Post: 01142009, 09:37 AM 
Generate a random number
By romina in forum New To JavaReplies: 1Last Post: 08072007, 06:23 AM 
How to generate random number in java
By fernando in forum New To JavaReplies: 1Last Post: 08012007, 08:32 PM
Bookmarks