Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

mupad: n choose k?

8 views
Skip to first unread message

Markus Dehmann

unread,
Mar 28, 2006, 10:51:49 PM3/28/06
to
Does anyone know how to do n choose k in mupad? I couldn't find it, not
even in the combinat package.

Thanks,
Markus

Joe Riel

unread,
Mar 29, 2006, 12:27:15 AM3/29/06
to
"Markus Dehmann" <markus....@gmail.com> writes:

> Does anyone know how to do n choose k in mupad? I couldn't find it, not
> even in the combinat package.
>

I don't know mupad, but does it have a binomial function?

--
Joe Riel

Mark Lawton

unread,
Mar 29, 2006, 3:32:37 AM3/29/06
to
You can write your own functions. I don't know how to do this in Mupad,
but here's a Maxima example:

Define a "combinations" function
(%i6) c(x,y) := x!/((x-y)! * y!);
(%o6) c(x,y):=x!/((x-y)!*y!)

Use it to calculate the number of ways to select 6 from 49 where the
order is not important (which equates to the odds of winning a
"Canadian style" lottery)
(%i7) c(49,6);
(%o7) 13983816

See
http://en.wikipedia.org/wiki/Permutations_and_combinations#Summary_of_formulae
for other combinatorical formulae.

Brad Cooper

unread,
Mar 29, 2006, 5:53:37 AM3/29/06
to

"Markus Dehmann" <markus....@gmail.com> wrote in message
news:1143604309.6...@e56g2000cwe.googlegroups.com...

> Does anyone know how to do n choose k in mupad? I couldn't find it, not
> even in the combinat package.

I think you require (for example)...

combinat::subsets::count(6,3);

This returns 20 as the number of combinations of 3 objects chosen from 6
i.e. 6!/(3!x3!)

Cheers, Brad

> Thanks,
> Markus
>


Jay Belanger

unread,
Mar 29, 2006, 8:29:57 AM3/29/06
to bela...@truman.edu
Joe Riel <jo...@k-online.com> writes:

Yes; good call.
>> binomial(10,4)
will return 10 choose 4.

Jay

0 new messages