On Wed, December 20, 2006 21:10, Allin Cottrell wrote:
On Wed, 20 Dec 2006, Andreas Karlsson wrote:
> I have a few suggestions for improvements of gretl, making it
> possible for me to use it in other courses:
>
> 1. A possibility to generate random binomial variables, for
> example by adding a menu entry Add > Random variable > Binomial
That would be easy enough. Also easy to do manually, for example
* add normal random variable, u
* genr binrand = u > 0
Actually, that would be a Bernoulli r.v. If I'm not mistaken, a binomial r.v.
is one for which (in LaTeX notation)
P(x=k) = n \choose k p^k (1-p)^{n-k}
It can be added quite easily. However, a little script will give you what you
want too:
scalar n = 10
scalar p = 0.4
series x = 0
loop n
x += (uniform()>p)
end loop
now x is binomial. True, this may be inelegant when n is big, but in that case
a binomial rv is practically Gaussian.
Riccardo (Jack) Lucchetti
Dipartimento di Economia
FacoltĂ di Economia "G. FuĂ "
Ancona