Is MATLAB's Randomization Function Affected by Appending Numbers to Student IDs?

  • Thread starter Thread starter emergentecon
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

The discussion centers on the behavior of MATLAB's randomization function when appending numbers to student IDs. Users reported consistently receiving the same output from the command rand("state",student_number) across different appended numbers. It was concluded that this method is outdated in newer versions of MATLAB, specifically R2012b and later, where the rng command should be used instead to set the state of the random number generator.

PREREQUISITES
  • Familiarity with MATLAB commands and syntax
  • Understanding of random number generation in programming
  • Knowledge of MATLAB version differences, particularly R2012b and later
  • Basic troubleshooting skills in coding environments
NEXT STEPS
  • Learn how to use the rng command in MATLAB for random number generation
  • Explore the differences between MATLAB versions regarding random number functions
  • Research best practices for generating reproducible random numbers in MATLAB
  • Investigate the implications of random number generation in statistical simulations
USEFUL FOR

Students using MATLAB for assignments, educators teaching MATLAB programming, and anyone interested in understanding random number generation in MATLAB.

emergentecon
Messages
57
Reaction score
0

Homework Statement



Enter the following two commands, and copy and paste the output as your answer
> rand("state",student_number0917);
> rand(1)
where student_number0917 is your student number with "0917" at the end and with "-" removed.
For example, if your student number is 123-456-7, you would enter
> rand("state",12345670917);
> rand(1)


The problem is, we need to do this for each new assignment, and for each new assignment, we append a new number: 0917 (in this instance), then 0913, 0920, 0911 etc.

However, I always get the same result, no matter what number I append?
Am I missing something?

Homework Equations



> rand("state",1234567?);
> rand(1)

The Attempt at a Solution



>> clc; clear;
>> rand('state',312754190917)
>> rand(1)

ans =

0.662733934182293

OR


>> clc; clear;
>> rand('state',312754190913)
>> rand(1)

ans =

0.662733934182293
 
Physics news on Phys.org
Yeah, that is the exact version I am using . . . cool, will look into it!
I have emailed my Prof. (included your post) :)

Thanks!
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 1 ·
Replies
1
Views
9K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 10 ·
Replies
10
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K