Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.4K Views
|
10 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Replicate Dave Giles' permutation test using WL?

10 Replies

Jim,

Actually, after rereading what you posted more carefully, I agree with you. You can obviously expand the approach I posted above to include 50000 samples:

Map[Permute[prices, #] & , RandomPermutation[Length[prices], 50000]]

but this would have the same duplicates as your approach and would be slower than what you posted.

I like your post best. I suppose you can always guarrantee no duplicates with:

DeleteDuplicates[
 Table[RandomSample[prices, Length[prices]], {i, 50000}]]

and it is still very fast (although duplicates are unlikely).

Regards,

Neil

POSTED BY: Neil Singer
Posted 6 years ago

Good idea, Neil. If one needed exactly 50,000 samples with no duplicates, just sample somewhat more than 50,000, delete duplicates, and then just use the first 50,000.

POSTED BY: Jim Baldwin

How about

Permute[prices, RandomPermutation[Length[prices]]]

This gives only one permutation and no duplicates.

Regards,

Neil

POSTED BY: Neil Singer
Posted 6 years ago
POSTED BY: Jim Baldwin
Posted 6 years ago

Just drop the use of Permutations.

prices = {5.0, 4.8, 4.7, 4.0, 5.3, 4.1, 5.5, 4.7, 3.3, 4.0, 4.0, 4.6, 5.3, 3.0, 
  3.5, 3.9, 4.7, 5.0, 5.2, 4.6};
samples = Table[RandomSample[prices, Length[prices]], {i, 50000}];
POSTED BY: Jim Baldwin
Posted 6 years ago

Just a simple comment: Your method is obviously more efficient than the OP's. However, the resulting collection of permutations will probably contain duplicates. While Rubens method will not.

POSTED BY: Hans Milton
Posted 6 years ago
POSTED BY: Jim Baldwin

Re that small probability: It appears to be a birthday paradox problem, and if I set it up correctly the probability is around 5*10^(-10).

POSTED BY: Daniel Lichtblau
Posted 6 years ago

Not that you need my confirmation but, yes, that is a good way to set up the problem:

1 - 50000! Binomial[20!, 50000]/(20!)^50000 // N
(* 5.13779*10^-10 *)

However, if you are seeing lots (or even one duplicate) when running the code, please buy a lotto ticket for me.

POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard