All problems
Density Under Linear Change of Variables
Problem
If X is normal with mean mu and standard deviation sigma, and Y = a*X + b with a != 0, then p_Y(y) = (1 / |a|) * phi((y - b) / a), where phi is the standard normal density.
Given y, mu, sigma > 0, a != 0, and b, return p_Y(y).
Hint
The absolute scale factor keeps the transformed density integrated to one for shrinking maps.
Test cases
case 1
in: [0,0,1,1,0]
expected: 0.3989422804014327
case 2
in: [0,0,1,2,0]
expected: 0.19947114020071635
case 3
in: [1,0,1,2,1]
expected: 0.19947114020071635
case 4
in: [0,0,1,-1,0]
expected: 0.3989422804014327
Starter codePython
def density_linear_transform(y, mu, sigma, a, b):
# Your code here
pass4 test cases · run your code against them in the editor