Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: RE: RE: estimate precision in MATA


From   Marie-Claire Robitaille-Blanchet <marie-claire.robitaille-blanchet@uwa.edu.au>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: RE: estimate precision in MATA
Date   Thu, 23 Sep 2010 10:38:58 +0800

Thanks!

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Stas Kolenikov
Sent: Wednesday, 22 September 2010 9:09 PM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: RE: RE: estimate precision in MATA

On Wed, Sep 22, 2010 at 2:25 AM, Marie-Claire Robitaille-Blanchet
<marie-claire.robitaille-blanchet@uwa.edu.au> wrote:
> Let say I want to sum two variables. I can use format to increase the number of digits after the decimal point for the new variable = old_variable_1 + old_variable_2.
>
> I'm looking for the equivalent but when I sum matrixes in MATA. So I want to increase the number of digit after the decimal point for the new matrix I'm creating from already existing matrixes. And, if possible, I would prefer the entry in the new matrix to be in the data type: double.

Mata already operates in double precision. If you need even higher
precision for your computations, there are -quad*()- functions
available. For each individual number, you can -printf()- it in the
format you like:

. mata
: pi()
  3.141592654

: printf("%20.18f",pi())
3.141592653589793100

Here, of course, the trailing zeroes are wrong, but Stata may have no
way of figuring out that they are.

-- 
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index