5745 Reputation

24 Badges

15 years, 144 days

MaplePrimes Activity

These are replies submitted by Christopher2222

I was just starting to get used to unapply.  The problem with that now is that future applications by people who prefer to use, or start using, MakeFunction will fail in older versions of Maple. 

In the first example on the help page I can see the logic of the new function.

This is the way I interpret it anyways - f equals make a function out of p in terms of x.  But it can be confusing because literally it says MakeFunction(p,x) - ok so what happened to p, I would kind of expect the variable p to be in the output. 

Anyways, it's a play on words.

@Carl Love Thanks Carl.  Indeed I thought order was playing a factor, and of course always a consideration.

Of course, the simulations are the more nteresting parts.

@mmcdara So problem 2 is what I was getting at.  And I see you've arrived at the same probability I came up with 1.11E-06 Setting the containers to be analogous to colored balls.  Carl love and you had some great code for me to digest. 


@Carl Love So I did this while I was falling asleep, and had to calculate it in the morning.  I get a different result than the one you found at the party. 

I think the analogy is close to a container with colored balls each.  Just picking all of family B and all of family C the probabilty works out as 4 choose 16 times 3 choose 15 etc ...

4/16*3/15*2/14*1/13*4/12*3/11*2/10*1/9 = 1.11*10^(-6)  Not sure yet, exactly why my result is 6x less in probability than your result. 

@Carl Love Yes you are correct the permutations do not have to be symmetric.  Thanks for the different approach.

Also thanks Mmcdara for the code you created, symmetric or not - a second drawing of the same family is not impossible but still highly improbable and all the more reason to be skeptical of the draw. 

@Carl Love ok thanks for randperm, in the meantime I've fixed what I had and gave the variables some random names.


hat := [a1, a2, a3, a4, b1, b2, b3, c1, c2, c3, c4, d1, d2, d3, d4, e1]

[a1, a2, a3, a4, b1, b2, b3, c1, c2, c3, c4, d1, d2, d3, d4, e1]




c := []; hat1 := hat; for i in hat do b := [i, hat1[(rand(1 .. nops(hat1)))()]]; while Has(b[1], b[2]) = true do b := [i, hat1[(rand(1 .. nops(hat1)))()]] end do; c := [op(c), b]; hat1 := [op(`minus`({op(hat1)}, {op(b[2])}))] end do; c

[[a1, d2], [a2, b3], [a3, c4], [a4, e1], [b1, a2], [b2, d4], [b3, c1], [c1, b2], [c2, a4], [c3, a1], [c4, d1], [d1, b1], [d2, c3], [d3, c2], [d4, a3], [e1, d3]]


names := {a1 = Thomas, a2 = Christine, a3 = Nolan, a4 = Michael, b1 = Charlie, b2 = Karen, b3 = Sandra, c1 = Brad, c2 = Kristen, c3 = Laurie, c4 = Austin, d1 = Sam, d2 = Natalie, d3 = Tamara, d4 = Zoey, e1 = Barbra}

subs(names, c)

[[Thomas, Natalie], [Christine, Sandra], [Nolan, Austin], [Michael, Barbra], [Charlie, Christine], [Karen, Zoey], [Sandra, Brad], [Brad, Karen], [Kristen, Michael], [Laurie, Thomas], [Austin, Sam], [Sam, Charlie], [Natalie, Laurie], [Tamara, Kristen], [Zoey, Nolan], [Barbra, Tamara]]




So Thomas will buy for Natalie, Christine will buy for Sandra, etc ...

So just developed a simple sample drawing from a hat.

Maybe not efficient but it's easy to follow.  So a little code for one random draw.


hat := [a1, a2, a3, a4, b1, b2, b3, c1, c2, c3, c4, d1, d2, d3, d4, e1]

[a1, a2, a3, a4, b1, b2, b3, c1, c2, c3, c4, d1, d2, d3, d4, e1]




c := []

for i to 8 do b := randcomb(hat, 2); while Has(b[1], b[2]) = true do b := randcomb(hat, 2) end do; c := [op(c), b]; hat := [op(`minus`({op(hat)}, {op(b)}))] end do; c

[[b3, d2], [c4, d4], [a2, b2], [b1, c2], [a4, c3], [a1, d3], [c1, d1], [a3, e1]]




edit *** oops, sorry that's only half of the draws. 

@Carl Love yes forensic mathematics!

So the odds if it happening 2 years in a row is so small that the chance that the drawing was fixed is a very high probability.  So caught red handed by induction.

Thanks both to your contributions. 

The number of adults and children I guess doesn't really matter.  What matters is that families can't choose other family members for a trade. 

I didn't give historical results, but for just one year back lets just say all of Family B had members trading with all of Family C the previous Christmas, and the same thing happened this Christmas.

How likely was it that the same Family B just so happens to trade with all of Family C again two years in a row?

Thanks Acer, mmacdara and Sand15 for your inputs.  Much appreciated.

mmacdara, I did see another post of yours with 2 dice - lengthy haven't gone through it yet.  I appreciate all the replies. 

To put things into perspective, cat out of the bag so to speak.  It all spurred from my son who wanted to randomly pick a 5 player team from the 120 common hockey cards from this years Tim Hortons Hockey card collection.  He only has a 6 sided dice, and he's memorized which player belongs to which number so randomly had to be done.  And had to do it simply enough for him - eneded up teaching him about modular numbers which he gets but it's many years ahead of his math level. 

@acer Thanks  This is good.

I also thought about dividing the 20 up a few times.  roll of 1-3 would select values 1 to 10 and 4-6 select 11 to 20. Then roll again to split that up 1-3 for 1-5 and 4-6 for 6-10 etc.

Then I was left with choosing 5 numbers with a 6 sided die.  Just to continue on this track for a minute, I would have a loop that would just roll again if a 6 came up - I thought that was the simplest way to settle that thought.  But I got stuck trying to develop a while loop that would work.  Got stuck with the recursive assignment.  Any suggestions for that type of loop?

@mmcdara Thanks for the inputs. 

[moderator: moved description of the OP's actual goal to the body of the original Question.]

@sand15 Interesting thanks.  I came up with something similar but it seems my way doesn't result in a uniform distribution. 

So picking a range from 1 to 20 using a six sided die I came up with this

d1 := RandomVariable(DiscreteUniform(1, 6)):

# for 500 samples of 4 rolls added
a := [seq((round(add(Sample(d1, 4))) mod 20) + 1, i = 1 .. 500)]


Distribution isn't fair.  Maybe your idea is better?

@Thomas Richard yeah, only values divisible by 3 are showing up. 
That is the sum of N rands only outputs solutions divisible by N.

Basically I was trying to use a 6 sided die to come up with a random number from a set range using mod.  Was looking at the distribution when I came across the rand issue.  Concluding me to look for another option.

Great post Daniel Skoog.  One thing though, your Lissajous knot is actually an unknot.  Using cos(7*t) produces a curve that can be unwound without knotting.  I believe you mean to use cos(5*t) which can not be unwound without knotting.


1 2 3 4 5 6 7 Last Page 1 of 154