My question is simple, and therefore I made a search of an answer to it using the Repository of this forum. There are relevant questions, however, none of them answers to the following question.
My first question is how to generate a list of lists (matrix) of RandomReal
numbers, but the repetitively generated lists should be monotonic (increasing or decreasing).
SeedRandom[213];
RandomReal[{0.3, 0.8}, 4];
(*output={0.5318, 0.412309, 0.571831, 0.673618}*)
In the next round of RealRandom
generation, every element in the list output
should be increased (or decreased) randomly within a small range, call the new output as output1
. In still another round, RandomReal
should generate another list output2
, every element of which should be greater than every corresponding element of output1
and so on.
My second question is more difficult (for me) since I also want some of the elements in the randomly generated list to remain unchanged, while others monotonically change. Namely, I like to control some elements during the process of random number generation.
Eventually, I like to combine the answers to these questions in a Mathematica
function, such as rng[...]:=
to automate the random number generations in the range of my interest.
EDIT 1
The type of Mathematica
function I have in mind has the following form:
f[inc_List, rngi_Range, rti_Real, dec_List, rngd_Range, rtd_Real,
fix_List, lrv_Integer, ni_Integer]
where
- inc_List = list of elements to be increased;
- rngi_Range = a range for the increment of
inc_List
;- rti_Real = rate of increase (real number in the interval [0,1]);
- dec_List = list of elements to be decreased;
- rngd_Range = a range for the decrease of
dec_List
;- rtd_Real = rate of decrease (real number in the interval [0,1]);
- fix = list of elements to be fixed;
- ni_Integer = number of times for Random # generation/number of iterations;
- lrv_Integer = length of the random vector;
output2
in round 2 do you userti
andrngi
to increase all elements ofoutput1
or only the elements in ininc
? $\endgroup$rti
andrngi
to increase the elements ininc
only. Similarly, I like to usertd
andrngd
to decrease the elements indec
only. $\endgroup${a,b,c,d,e,f,g,h}
, some of which should increase like{a,b,c}
, some decrease like{d,e,f}
, while still others like{g,h}
are fixed. A new value for each element in each group should be randomly selected but in the desired direction such as increase, decrease and fix. $\endgroup$