On Apr 7, 2010, at 9:29 AM, Kenneth A. Ribet wrote:

Hello All,

I asked myself how I could use sage to compute the standard deviation of a grade distribution for one of my courses. Rooting around, I found that I can compute for example

sage: vector(RDF,[1,2,2,1]).standard_deviation()

and get the answer 0.57735026919. However, if I try the same command with "RDF" replaced by "RR," I get anAttributeError. My first question is: What's going on here; how come RDF and RR are so different in this context? Their respective descriptions look very similar --

Because no one's yet taken the time to unify the interfaces yet (the two different "rings" use different implementations under the hood-- the one for RDF is optimized as a double* whereas the one for RR is just the generic one). It would probably make sense to put a standard_deviation method higher up the inheritance tree.

To be clear, I consider this a bug (fortunately easy to fix) and a ticket should be filed.

"An approximation to the field of real numbers using double precision floating point numbers. Answers derived from calculations in this approximation may differ from what they would be if those calculations were performed in the true field of real numbers. This is due to the rounding errors inherent to finite precision calculations."

"An approximation to the field of real numbers using floating point numbers with any specified precision. Answers derived from calculations in this approximation may differ from what they would be if those calculations were performed in the true field of real numbers. This is due to the rounding errors inherent to finite precision calculations."

If I had found some documentation about the standard deviation command, I would probably have have found the answer to my first question. This leads to my second question: Why I don't I see information about standard_deviation when I type "standard_deviation?" at the command line?


Sage has an object-oriented design, which is to say that functions are attached to objects rather than all dumped into the global session. This allows stuff like

sage: v = vector(RDF, [1,2,2,1])
sage: v.norm()
3.16227766017
sage: I = NumberField(x^3-x+1, 'a').ideal(2)
sage: I.norm()
8

where doing v.norm? and I.norm? can give good contextual information given the wide variety of objects and paradigms that Sage supports (and it makes tab completion work much smoother too). I could see a case for standard_deviation being a top-level function though, like we do for many other basic operations. (Typically f(X) calls X.f()).

- Robert

--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using "remove me" as the subject.

Reply via email to