Hi Matthew, Matthew J wrote: > Sage is great software that I rave about in pretty much all of my > classes except for probability theory. I’d like to get some info on a > few topics to clear some things up so that I can use these for classes > and to post to an examples worksheet. Thanks in advance to anyone that > replies. > > I am wondering how to do a few things. > Is there a better (built-in) way to do simple combinations/ > permutations than writing a function like > > def choose(n,k): return factorial(n)/(factorial(k)*factorial((n-k))) > Entering: binomial(5,2) will return: 10
Is this what you want? (This is much more efficient than the 'choose' function you have above.) > or equivalent for permutations? > I'm not sure exactly what you mean here. factorial(n) counts the number of permutations of 'n' elements very efficiently. Perhaps you mean sage: permutations([1,2,2]) [[1, 2, 2], [2, 1, 2], [2, 2, 1]] Type permutations? for more information on this command. You may also be interested in the command 'combinations'. > ----- > > Is there a way to get the Standard Normal CDF other than writing the > function explicitly like below? > > def normalCDF(z): > t = var('t') > return N(integrate((1/sqrt(2*pi))*e^((-t^2)/2), t, -infinity, z)) > ----- > > Also, are there any distributions built into sage? I don’t quite know > what working with a distribution symbolically would be like, but as an > example, perhaps being able to do something like > X ~ BIN(n, p) and then get the expected value, variance, or PDF of X? > Assume that n and p are given. > *Lots* of statistics is built into sage with the 'R' package. I don't know it well, but you can try typing R? inside sage and see what you can work out from there. Cheers, Jason > Thanks, > -Matthew J > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---