Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: mata (simple): generating random numbers


From   "Feiveson, Alan H. (JSC-SK311)" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: mata (simple): generating random numbers
Date   Thu, 1 Nov 2007 15:16:01 -0500

Thanks for pointing this out,Tom. I was led astray by 

"uniform() is the same function as Stata's uniform() function. "

After seeing this,I didn't even notice that the arguments were
different. But in view of the fact that for some functions, the
arguments are not the same in Stata as in Mata, I don't see why the Mata
manual can't simply give the correct arguments? As written without
arguments, the list in [M-4] does not supply useful information.

Al

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Steichen,
Thomas J.
Sent: Thursday, November 01, 2007 3:01 PM
To: [email protected]
Subject: st: RE: mata (simple): generating random numbers

Al, there is documentation (help mf_uniform):

help mata uniform()
------------------------------------------------------------------------
-----------------------

Title

    [M-5] uniform() -- Uniformly distributed random numbers


Syntax

        real matrix   uniform(real scalar r, real scalar c)

        string scalar uniformseed()

        void          uniformseed(string scalar newseed)

        void          uniformseed(real scalar newseed)


Description

    uniform(r, c) returns an r x c real matrix containing uniformly
distributed random
    numbers 0 < element < 1.  uniform() is the same function as Stata's
uniform() function.

    uniformseed() returns uniform()'s current seed in encrypted, string
form.  uniformseed()
    returns the same thing as Stata's c(seed); see [D] generate and [P]
creturn.

    uniformseed(newseed) sets the seed:  a string previously obtained
from uniformseed() may
    be specified for the argument, or an integer number may be
specified.  uniformseed() has
    the same effect as Stata's set seed command; see [D] generate.


Conformability

    uniform(r, c):
                r:  1 x 1
                c:  1 x 1
           result:  r x c

    uniformseed():
           result:  1 x 1

    uniformseed(newseed):
          newseed:  1 x 1
           result:  void


Diagnostics

    uniform(r, c) aborts with error if r<0 or c<0.

    uniformseed(seed) aborts with error if a string seed is specified
and it is malformed
    (was not obtained from uniformseed()).


Source code

    Functions are built in.


Also see

    Manual:  [M-5] uniform()

    Online:  [M-4] standard, [M-4] statistical 



-----------------------------------
Thomas J. Steichen
[email protected]
-----------------------------------
 
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Feiveson,
Alan H. (JSC-SK311)
Sent: Thursday, November 01, 2007 3:47 PM
To: [email protected]
Subject: st: mata (simple): generating random numbers

Hi -I've been frustrated by trying to simply generate random uniforms
using uniform()in Mata: Here's what happens:

.. mata
------------------------------------------------- mata (type end to
exit) ---------------------------
: A = 1..5

: E=exp(A)

: A
       1   2   3   4   5
    +---------------------+
  1 |  1   2   3   4   5  |
    +---------------------+

: E
                 1             2             3             4
5
 
+-----------------------------------------------------------------------
+
  1 |  2.718281828   7.389056099   20.08553692   54.59815003
148.4131591  |
 
+-----------------------------------------------------------------------
+

: F=normal(A)

: F
                 1             2             3             4
5
 
+-----------------------------------------------------------------------
+
  1 |  .8413447461   .9772498681    .998650102   .9999683288
..9999997133  |
 
+-----------------------------------------------------------------------
+

: U=uniform()
wrong number of arguments for uniform()
r(3000);

: U=uniform():*1
wrong number of arguments for uniform()
r(3000);

: U=uniform():*A
wrong number of arguments for uniform()
r(3000);

What am I doing wrong? Also, nowhere in the Mata manuals can I find
anything about what arguments the statistical functions take. After
going to interactive  "help', I finally found out they were the same as
the Stata function arguments. So if that's true, why doesn't "uniform()"
work?

Al Feiveson

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

-----------------------------------------
CONFIDENTIALITY NOTE: This e-mail message, including any attachment(s),
contains information that may be confidential, protected by the
attorney-client or other legal privileges, and/or proprietary non-public
information. If you are not an intended recipient of this message or an
authorized assistant to an intended recipient, please notify the sender
by replying to this message and then delete it from your system. Use,
dissemination, distribution, or reproduction of this message and/or any
of its attachments (if
any) by unintended recipients is not authorized and may be
unlawful.   

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index