A bug in pearsrnd?

10 views (last 30 days)
Ulrik William Nash
Ulrik William Nash on 7 Nov 2018
Edited: John D'Errico on 7 Nov 2018
With the following values for mean, std, skewness, and kurtosis, pearsrnd stalls without warning:
mean = -9.0000e-08 std = 0.6400 skewness = 2.2500e-19 kurtosis = 3.0000
Is it just my system, or do other people experience the same event?
  2 Comments
David Goodmanson
David Goodmanson on 7 Nov 2018
Edited: David Goodmanson on 7 Nov 2018
Hi Ulrik,
Works for me in version 2017b. But it does have some interesting behavior. For your four parameter values with the minuscule but nonzero value of skewness,
[a b] = pearsrnd(mean,std,skewness,kurtosis,1,10)
gives 10 identical draws that all equal the mean, and pearson type 3. If you change the skewness to 0, the function gives sensible values for the draws and pearson type 0 (normal distribution) as it should.
Ulrik William Nash
Ulrik William Nash on 7 Nov 2018
Hi David, later today I did notice that MATLAB outputs something, but it strangely takes much longer than normal under the specified setting.

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 7 Nov 2018
Edited: John D'Errico on 7 Nov 2018
I'm not amazed. These things can be tricky. Looks like pearsrnd is tripping over the very near zero skewness.
X = pearsrnd(-9.0000e-08,0.6400,0, 3.0000,1,10)
X =
Columns 1 through 7
-0.66873960681121 0.271599778145953 0.316496827107004 -0.557976990199874 -0.0679667761010375 -0.00640246071921475 -0.322436885401314
Columns 8 through 10
0.143696162106232 -0.024154191418116 -0.148957358392865
X = pearsrnd(-9.0000e-08,0.6400,2.25e-19, 3.0000,1,10)
X =
Columns 1 through 7
-9e-08 -9e-08 -9e-08 -9e-08 -9e-08 -9e-08 -9e-08
Columns 8 through 10
-9e-08 -9e-08 -9e-08
Yet, we see this, if we make the skewness a bit larger.
X = pearsrnd(-9.0000e-08,0.6400,2.25e-8, 3.0000,1,10)
X =
Columns 1 through 7
0.106139493587646 -0.217350258228149 -0.758287810680237 -1.06893690049347 0.127482009533081 -0.661103934642639 0.233781877163086
Columns 8 through 10
0.858859763744507 0.170714274051819 0.595377956035767
So it seems to be working properly here again. The way these things work is they test the parameters, depending on where they live, you get a different distribution. But some of those distributions can be rather nasty as I recall. So it looks like pearsrnd is getting stuck in a rabbit hole, depending on the value of skewness. Technically, a bug I guess, worth reporting as such.
The speed differential is not a bug though, just a feature. ;-)) Again, when you change parameters, the underlying distribution must some times change. And some distributions are MUCH, MUCH simpler to sample from. (One of the flaws with distribution systems like Pearson and Johnson families.)

More Answers (0)

Tags

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!