Messages from list : cormas@cirad.fr

Choose a topic among the following archives :

RE: smallTalk programming a binomial function with mean = X?

New Message Reply Date view Thread view Subject view Author view

Subject: RE: smallTalk programming a binomial function with mean = X?
From: Bruno Bonte (bruno.bonte@hotmail.fr)
Date: Wed Mar 18 2009 - 20:01:47 CET

Hello Medhi,

If you need a random number generator, I think it is allways better to use Cormas predefined ones because they all use the same seed which allows you for example to run several times exactly the same simulation if you fix the seed.

Cheers,
Bruno

> From: nicolas.becu@gmail.com
> To: cormas@cirad.fr
> Subject: RE: smallTalk programming a binomial function with mean = X?
> Date: Wed, 18 Mar 2009 18:29:40 +0100
>
> Dear Mehdi
>
> Another way is to use an already existing function of the cormas kernel (see
> the cormas glossary that you can download on the website).
>
> IN your case it is possible that the following method will help
> Cormas normal: X sigma: stDev
> (where X is your mean, and stDev is the standard deviation of your
> normal distribution)
>
> You can call this method from anywhere, ... just use the keyword 'Cormas'
> before (as in Cormas random).
>
> Regards,
>
> Nicolas
>
>
>
> -----Message d'origine-----
> De : owner-cormas@cirad.cirad.fr [mailto:owner-cormas@cirad.cirad.fr] De la
> part de Serge Stinckwich
> Envoyé : mercredi 18 mars 2009 16:32
> À : vanvlietnathalie@yahoo.com; cormas@cirad.fr
> Objet : Re: smallTalk programming a binomial function with mean = X?
>
> This is quick and dirty method in order to solve your problem.
> You have to check it before use it.
>
> 1) Create a BinomialDistributionGenerator with 3 instances variables :
> n, p and gen
> 2) Create the following methods :
>
> BinomialDistributionGenerator >>initialize
> gen := Random new
>
> BinomialDistributionGenerator >>n: anInteger
> n := anInteger
>
> BinomialDistributionGenerator >>p: aProbability
> p := aProbability
>
> BinomialDistributionGenerator>>next
> | x |
> x := 0.
> n
> timesRepeat: [gen next <= p
> ifTrue: [x := x + 1]].
> ^ x
>
> In order to use it in VisualWorks Smalltalk, you have to add i guess a
> new class method (In Squeak, the initialize method is automatically
> called) :
>
> BinomialDistributionGenerator class>> new
> ^super new initialize
>
> 3) You can use it like this example :
>
> b := BinomialDistributionGenerator new.
> b p: 0.5; n:10.
> b next.
>
>
> On Wed, Mar 18, 2009 at 2:40 PM, Mehdi Saqalli <msqalli@yahoo.com> wrote:
> > Hello to All!
> > do someone can help us ?
> > how to write a binomial function with a mean = X in SmallTAlk?
> > thanks in advance
> >
> >
> > ***************************************************
> > Mehdi Saqalli
> > LMTG - UMR 5563 UR 154 CNRS Université Paul-Sabatier IRD
> > Observatoire Midi-Pyrénées - 14, avenue Edouard Belin - 31400 Toulouse,
> > France
> > fax : +33 (0)5 61 33 25 60 tel.: +33 (0)5 61 33 26 56 / +33 (0)6 16 03 80
> 37
> > courriel: saqalli@lmtg.obs-mip.fr / msqalli@yahoo.com
> > web : www.lmtg.obs-mip.fr / www.padniger.net /
> > www.enge.ucl.ac.be/staff/past/saqalli.htm
> >
>
>
>
> --
> Serge Stinckwich
> UMI UMMISCO 209 (IRD/UPMC), Hanoi, Vietnam
> Smalltalkers do: [:it | All with: Class, (And love: it)]
> http://doesnotunderstand.org/
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.0.238 / Virus Database: 270.11.18/2009 - Release Date: 03/18/09
> 07:17:00
>
>

_________________________________________________________________
Inédit ! Des Emoticônes Déjantées! Installez les dans votre Messenger !
http://www.ilovemessenger.fr/Emoticones/EmoticonesDejantees.aspx

New Message Reply Date view Thread view Subject view Author view
 

Back to home