randn() precision limited to 55 digits
%randn ignores high precision
mp.Digits(1034)
t=randn(1,'mp')
t =0.1048747160164939795645722142580780200660228729248046875
t - 0.1048747160164939795645722142580780200660228729248046875
ans = 0
MATLAB Version 9.14 (R2023a)
Advanpix Multiprecision Computing Toolbox Version 5.2.8.15537
Respuesta
The rand(...,'mp') generates numbers in double precision and then converts them to mp. Hence digits are not filled up to the 1034th digit. We do this in order to produce the same random numbers as built-in MATLAB's rand function (for reproducibility).
If you want random numbers to the full precision (all 1034 digits are filled), please use mprand/mprandn.
>> mp.Digits(100);
>> randn(1,'mp')
ans =
0.8621733203681205548463140075909905135631561279296875
>> mprandn(1,'mp')
ans =
0.1868724737876430395187949415904261118721051078748075419355524734700877850288747581541290481709356331
mprand() and mprandn() appear nowhere in the documentation nor on the Advanpix site;
Google search is empty: mprandn site:advanpix.com
Syntactically, function calls to mprandn(n) are expected equivalent to randn(n,'mp').
Sure looks like a bug to me.
Agree, this is lack of documentation. The mprand(n) was an experimental name, I just left it for the time being.
Please suggest other name, unambiguous enough. Thank you.
Servicio de atención al cliente por UserEcho
The rand(...,'mp') generates numbers in double precision and then converts them to mp. Hence digits are not filled up to the 1034th digit. We do this in order to produce the same random numbers as built-in MATLAB's rand function (for reproducibility).
If you want random numbers to the full precision (all 1034 digits are filled), please use mprand/mprandn.