middle square algorithm in MATLAB

How to do the following question:
Use the middle square algorithm which takes a seed (max 8-digits), squares the middle 4 to return a new random number (normalized so the range is 0-1). The returned value is used as the seed for the next draw, if the number has less than 8 digits, pad the beginning of the number with zeros before selecting the middle four digits. for example, set seed 00159839 in the begining

1 Kommentar

Geoff Hayes
Geoff Hayes am 1 Feb. 2019
mengke - what have you tried so far? Why do you need to normalize the number to the range 0-1? Isn't this the psuedo random number whose middle four digits you extract (padding if necessary) to generate a new pseudo random number? How would you do that if the number is normalized?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Random Number Generation finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 31 Jan. 2019

Kommentiert:

am 1 Feb. 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by