AllenDowney / ThinkStats2

Text and supporting code for Think Stats, 2nd Edition
http://allendowney.github.io/ThinkStats2/
GNU General Public License v3.0
4.02k stars 11.31k forks source link

missing log-log scale in solution for Weibull transform (chap05soln.ipynb) #206

Closed rjoberon closed 3 months ago

rjoberon commented 1 year ago

The solution for the exercise in Chapter 5 to create a transformation which shows a straight line for Weibull distributed data is missing the log-log transformation:

sample = [random.weibullvariate(2, 1) for _ in range(1000)]
cdf = thinkstats2.Cdf(sample)
thinkplot.Cdf(cdf, transform="weibull")
thinkplot.Config(xlabel="Weibull variate", ylabel="CCDF")

The last line should be

thinkplot.Config(xlabel="Weibull variate", ylabel="CCDF", xscale="log", yscale="log")

instead. Then we get a straight line also for other values of k then just k=1.

(This seems to be a bit more complex, since thinkstats.Cdf correctly sets xscale and yscale to "log" but the scale return value of thinkstats.Cdf is not used here. Another option would be to replace the last two lines with

scale = thinkplot.Cdf(cdf, transform="weibull")
thinkplot.Config(xlabel="Weibull variate", ylabel="CCDF", xscale=scale["xscale"], yscale=scale["yscale"])

but that's less transparent.)

AllenDowney commented 3 months ago

Will fix. Thank you!