# Why is the plot of a PDF not equivariant under changes of units?

Posted 2 years ago
2311 Views
|
|
2 Total Likes
|
 Consider the following two pieces of Wolfram language code: Plot[PDF[NormalDistribution[Quantity[0, "Meters"], Quantity[1, "Meters"]], x], {x, Quantity[-2, "Meters"], Quantity[2, "Meters"]}] Plot[PDF[NormalDistribution[Quantity[0, "Angstroms"], Quantity[1, "Angstroms"]], x], {x, Quantity[-2, "Angstroms"], Quantity[2, "Angstroms"]}] These two produce vastly different plots, even though the plots should be the same, especially since sampling the PDFs and then mapping QuantityMagnitude to the results gives the same numerical values for both cases. See the attached notebook. Attachments: Answer
 I avoid using units but maybe that's just me being ignorant.The "fix" however seems a bit subtle. Here's what works: Plot[PDF[NormalDistribution[Quantity[0, "Meters"], Quantity[1, "Meters"]], Quantity[x, "Meters"]], {x, -2, 2}] Plot[PDF[NormalDistribution[Quantity[0, "Anstroms"], Quantity[1, "Angstroms"]], Quantity[x, "Angstroms"]], {x, -2, 2}] So using Quantity on the argument of PDF rather than the range of values for Plot makes things work. Answer