[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Generate a vector of predetermined numbers
From: |
Bård Skaflestad |
Subject: |
Re: Generate a vector of predetermined numbers |
Date: |
Mon, 8 Jul 2013 15:41:42 +0200 |
On Sun, 2013-07-07 at 02:20 -0700, simia wrote:
> I simply have to generate in Octave a 1xn vector of predetermined
> numbers. I have to generate a 1xn random sequence of 0.7 and 1.8.
I don't quite understand what you want. Do you want a sequence
containing *only* the numbers 0.7 and 1.8 or do you want a sequence
drawn from the interval [0.7, 1.8]?
In the first case, I suggest doing something like this:
vals = [ 0.7, 1.8 ];
seq = vals(ceil(2 * rand([1, n])));
In the second, you could probably get away with
vals = [ 0.7, 1.8 ];
seq = vals(1) + diff(vals)*rand([1, n]);
Of course, the *applicability* of either of these suggestions depends (a
lot) on the statistical properties needed in your application.
Sincerely,
--
Bård Skaflestad <address@hidden>
SINTEF ICT, Applied Mathematics