# Re: st: mata (simple): generating random numbers

 From "Abdel Rahmen El Lahga" To statalist@hsphsun2.harvard.edu Subject Re: st: mata (simple): generating random numbers Date Thu, 1 Nov 2007 21:17:48 +0100

```Alan,
what is wron is the syntax of uniform function. uniform() can be used
under Stata, but under mata you should use uniform(r,c) (r: row
dimension c: col dimension). for your exemple you can write
A=1..5
U=uniform(rows(A),cols(A)) :* A

2007/11/1, Feiveson, Alan H. (JSC-SK311) <alan.h.feiveson@nasa.gov>:
> 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/
>

--
AbdelRahmen El Lahga
*
*   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/
```