On Fri, Nov 13, 2009 at 2:14 PM, Vincent Delecroix
20100.delecr...@gmail.com wrote:
Hi,
A basic example from statistics which I like for its simplicity :
{{{
sage: marks = [1, 4, 2, 5.65, 3, 2.28] # the marks of my students
sage: mean = sum(marks) / len(marks)
sage: print mean
2.988333
sage: variance = sum([(mark-mean)^2 for mark in marks]) / len(marks)
sage: print variance
2.2566805556
}}}
Shameless plug for a patch I have a student working on:
http://trac.sagemath.org/sage_trac/ticket/7197
There is also a nice prod in SAGE similar to sum. It can be used as
example for factorial :
{{{
sage: prod(range(1,2))
1
sage: prod(range(1,3))
2
sage: prod(range(1,4))
6
sage: prod(range(1,5))
24
}}}
or for the smallest number dividing by primes in an interval
{{{
sage: prod(prime_range(1,10))
210
}}}
Vincent
--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sage-combinat-devel group.
To post to this group, send email to sage-combinat-devel@googlegroups.com
To unsubscribe from this group, send email to
sage-combinat-devel+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sage-combinat-devel?hl=en
-~--~~~~--~~--~--~---