Message Boards Message Boards

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

Posted 4 years ago

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:
POSTED BY: Kabelo Moiloa
Posted 4 years ago

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.

POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract