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

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

From   "Steichen, Thomas J." <>
To   <>
Subject   st: RE: mata (simple): generating random numbers
Date   Thu, 1 Nov 2007 16:01:16 -0400

Al, there is documentation (help mf_uniform):

help mata uniform()


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


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

        string scalar uniformseed()

        void          uniformseed(string scalar newseed)

        void          uniformseed(real scalar newseed)


    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.


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

           result:  1 x 1

          newseed:  1 x 1
           result:  void


    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
-----Original Message-----
From: [] On Behalf Of Feiveson, Alan H. (JSC-SK311)
Sent: Thursday, November 01, 2007 3:47 PM
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
  1 |  2.718281828   7.389056099   20.08553692   54.59815003
148.4131591  |

: F=normal(A)

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

: U=uniform()
wrong number of arguments for uniform()

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

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

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()"

Al Feiveson

*   For searches and help try:

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

*   For searches and help try:

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