Random multiply by negative one
Mostra commenti meno recenti
Hello, I bootstrapped a 1000 simulation from my data with replacement and now, I would like to randomly multiply it by one or negative one, but I am not sure how to do that.
My initial guess was to do the following: y3=y2*randi([-1,1],22528,1000), but I guess it will generate pseudorandom integers in this range, which includes zero. Any suggestion on how to do this will be highly appreciated.
Thanks
Alma
Risposte (3)
Try this:
A = [1,-1];
rand_nums = A(randi([1,2],22528,1000));
Azzi Abdelmalek
il 22 Feb 2016
Modificato: Azzi Abdelmalek
il 22 Feb 2016
out=2*randi([0 1],22528,1000)-1
Alma Bezares
il 22 Feb 2016
0 voti
1 Commento
jgg
il 22 Feb 2016
You should accept the answer then, so other people can see the solution!
Categorie
Scopri di più su Random Number Generation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!