Results 1 to 10 of 10
- 03-09-2012, 07:46 AM #1
Member
- 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:
Could you advince how to solve my problem?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!
- 03-09-2012, 03:10 PM #2
Member
- 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??
- 03-09-2012, 03:16 PM #3
Member
- Join Date
- Mar 2012
- Posts
- 5
- Rep Power
- 0
Re: Generate random number in evaluation score
Last edited by Tianma; 03-09-2012 at 03:20 PM.
- 03-11-2012, 07:40 PM #4
Member
- 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 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.
- 03-12-2012, 06:15 AM #5
Member
- 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; 03-12-2012 at 10:54 AM.
- 03-12-2012, 09: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?
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 03-12-2012, 10:09 AM #7
Member
- 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; 03-12-2012 at 10:39 AM.
- 03-12-2012, 10: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)
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 03-12-2012, 11:17 AM #9
Member
- Join Date
- Mar 2012
- Posts
- 5
- Rep Power
- 0
- 03-12-2012, 03:00 PM #10
Member
- Join Date
- Mar 2012
- Posts
- 5
- Rep Power
- 0
Re: Generate random number in evaluation score
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?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: 08-12-2011, 04:49 PM -
Can I get random.util not to generate the same number twice
By lilleza87 in forum New To JavaReplies: 3Last Post: 10-24-2010, 10:24 PM -
Trying to Generate Random number
By PeterFeng in forum New To JavaReplies: 10Last Post: 01-14-2009, 08:37 AM -
Generate a random number
By romina in forum New To JavaReplies: 1Last Post: 08-07-2007, 05:23 AM -
How to generate random number in java
By fernando in forum New To JavaReplies: 1Last Post: 08-01-2007, 07:32 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks