views:

503

answers:

2

I have to generate two random sets of matrices Each containing 3 digit numbers ranging from 2 - 10

like that

matrix 1: 994,878,129,121

matrix 2: 272,794,378,212

the numbers in both matrices have to be greater then 100 and less then 999

BUT

the mean for both matrices has to be in the ratio of 1:2 or 2:3 what ever constraint the user inputs

my math skills are kind of limited so any ideas how do i make this happen?

+1  A: 
Bill the Lizard
makes sense let me try that thanks a million!!
I tried the solution but its almost impossible to get the right value the program keeps on loopingexpectedTotal: 4322second matrix: 537,178,569Sum of the matrix : 1284fourth number: 3038is there something i am missing
How are you seeding the random number generator?
Bill the Lizard
first matrix 100- 499second 100-999
I mean, what are you using to get random numbers? Like, in Java, you'd use Random rand = new Random();, then use rand.nextInt(1000);. How are you doing that?
Bill the Lizard
+1  A: 

You have a set of random numbers, s1.

s1= [ random.randint(100,999) for i in range(n) ]

For some other set, s2, to have a different mean it's simply got to have a different range. Either you select values randomly from a different range, or you filter random values to get a different range.

No matter how many random numbers you select from the range 100 to 999, the mean is always just about 550. The odds of being a different value are exactly the normal distribution probabilities on either side of the mean.

You can't have a radically different mean with values selected from the same range.

S.Lott
range has to be the same, the mean has to be different.
Sorry, but if the range is the same, and the numbers are truly random, the expected value of the mean will be the same. Pick any two from (same range, random, different means).
Brent.Longborough
@Brent Longborough: The original question is either misstated or is a logical contradiction.
S.Lott