E28: Mobile Robotics - Fall 2015 - HOMEWORK 10
1. Tent-shaped continuous probability distribution
We will design a program to sample from a tent-shaped probability density function, as pictured below:
Note that p(x) = 0 for x ∉ [0, 1].
a. What must the height h of the tent be, and why? Use your answer to derive a piecewise-linear function defining the probability density function p(x) for the domain x ∈ [0, 1].
b. Derive a piecewise quadratic cumulative distribution function cdf(x) for the domain x ∈ [0, 1].
c. Finally, derive the inverse function cdf-1(q) for q ∈ [0, 1].
d. Write a program to plot p(x), cdf(x), and cdf-1(q) over the unit interval.
e. Write a program to sample from p(x) by mapping a uniformly generated random number q ∈ [0, 1] through the inverse distribution function. Demonstrate the effectiveness of your method by generating a histogram showing the frequencies of 10,000 total samples in 20 equally spaced bins over the unit interval (i.e. each with a width of 0.05).