Message Boards Message Boards

0
|
1704 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Multiplication of randomly selected numbers over a certain value

Posted 5 years ago

How do I find the k value greater than 50 in how many attempts? And I want to add number of all attempts into a list.

liste = RandomReal[{1, 10}, 100];
liste2 = RandomReal[{1, 10}, 100];
m = RandomChoice[liste]
n = RandomChoice[liste2]
k = m*n

For example:

First attempt is
m=2.62987
n=7.9005
k=m*n=20.7773

Second attempt is
m=5.20733
n=3.49277
k=m*n=18.188

Third attempt is
m=9.75211
n=8.80641
k=m*n=85.881

Wanted list = {20.7773,18.188,85.881}
POSTED BY: Nagon Stewart
Posted 5 years ago
randomProduct[] := Times @@ RandomChoice[RandomReal[{1, 10}, 100], 2]
Table[randomProduct[], 50]

Gives:

{63.9891, 17.9557, 87.3198, 32.9473, 15.1637, 29.7669, 51.645, 
12.7526, 16.6779, 77.3897, 15.1959, 38.085, 16.4897, 6.1858, 30.7647, 
42.773, 41.4649, 7.54359, 46.9427, 24.5257, 89.7559, 51.1646, 
59.8884, 47.4572, 5.01737, 11.0181, 3.32749, 8.41211, 6.10643, 
90.1455, 10.3041, 13.508, 10.7007, 80.044, 22.2968, 76.9739, 55.2836, 
46.5379, 53.2397, 18.9813, 14.0878, 25.316, 56.0477, 15.1871, 
13.3755, 15.2659, 26.7804, 18.8224, 27.1496, 6.9052}

To split and count how many are > 50

GroupBy[Table[randomProduct[], 50], # > 50 &] // Map[Length]
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract