From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Random number generation
Date: Sat, 14 Mar 2009 19:37:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 22
Message-ID: <gph10t$2bo$>
References: <gpgnsd$3kc$> <gpgtcn$ra1$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1237059421 2424 (14 Mar 2009 19:37:01 GMT)
NNTP-Posting-Date: Sat, 14 Mar 2009 19:37:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 816492
Xref: comp.soft-sys.matlab:524902

"Roger Stafford" <> wrote in message <gpgtcn$ra1$>...
> "Kiril " <> wrote in message <gpgnsd$3kc$>...
> > Hi, everyone I'm new to Matlab and I need help...
> > I need to generate random number i bounds for example [-1, 50], and need to generate and floating number in bound but with some precision, for example 4 digits after point [-0.1236 125.1020]. I have to write function and when i pass precision and LB , RB to return vector with rand float numbers and have to write the same function but working with real numbers. Thanks... can some one help me ?
>   Your description of the problem is not at all clear, and I am forced to make a wild guess.  You want to generate random values that are uniformly distributed on values discretely-spaced apart by some negative power of ten, as in:
>  [19.1234 19.1235 19.1236 ... 125.1019 125.1020]
> Does that come anywhere near what you want?
>   In this particular case you could do:
>  x = floor((1251020-191234+1)*rand(1,n)+191234)*.0001;
> for n such random values.  I will let you work out the proper generalization of this.
>   You should realize that because matlab uses binary floating point numbers, it cannot exactly represent the majority of such decimal fractions.  For example it cannot give you an exact 0.1 value but only one that is within round-off error of that.
> Roger Stafford

I try to write genetic algorithm for calculate AC motor efficiency by using induction motor equivalent circuit. And i started wit binary type of GA, but my fitness function have 5 params, (from AC motor equivalent circuit: Rs, Rr, Xls, Xlr, Xm) and algorithm doesn't work very good. So i want to rewrite it with floating number and i hope to works better. But so that for init Pop and for genetic operator i need random number generator. But the problem is what generator must generate numbers in GA params domains... The domain for Rs for example is [5, 15], and the value form field test is Rs=10.2 Ohm. So i need generator which can make random numbers in special domain with special precision after point. ( i use 4 digits after point so now). The function I need must have 3 input param:LB, RB and precision... i try to make it all day but nothing...... Do you have any ideas?