[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Difference between random number seed between octave and matlab
From: |
Peng Yu |
Subject: |
Difference between random number seed between octave and matlab |
Date: |
Sat, 22 Jun 2013 20:23:37 -0500 |
Hi,
It seems that each time matlab starts, it uses the same seed but
octave does not. See below for demonstration. (mlb.sh is just a
wrapper to matlab so that it accept input from stdin.) Does anybody
where this is documented in matlab and octave?
~/linux/test/octave/matlab/lang/function/randn$ cat main.m
#!/usr/bin/env bash
shopt -s lastpipe; tail -n +3 "$0" | exec /usr/bin/env mlb.sh
randn
~/linux/test/octave/matlab/lang/function/randn$ ./main.m
>> >>
ans =
0.5377
~/linux/test/octave/matlab/lang/function/randn$ ./main.m
>> >>
ans =
0.5377
~/linux/test/octave/octave/lang/function/randn$ ./main.m
ans = 1.1670
ans =
-0.24059 0.84457 2.06545
2.57006 -1.60635 0.37254
0.82313 0.18364 -1.61877
ans =
0.345635 0.714953 0.022038 -0.939530
-1.114125 0.135750 -1.117729 1.749078
-0.245421 0.299924 -0.634159 0.773315
~/linux/test/octave/octave/lang/function/randn$ ./main.m
ans = 0.45906
ans =
1.4029686 -0.0407457 -0.1168094
-1.1502772 -1.2197264 -0.8701638
0.0082042 0.8846563 -1.4461442
ans =
-1.007959 -0.686997 1.465105 -0.347564
0.640916 -1.456063 0.866900 -0.784564
-0.549065 -0.051180 0.249265 0.755601
~/linux/test/octave/octave/lang/function/randn$ cat main.m
#!/usr/bin/env octave -q
randn
randn(3)
randn(3, 4)
--
Regards,
Peng
- Difference between random number seed between octave and matlab,
Peng Yu <=