Before visualizing a function in detail, it often helps to look for some global properties that constrain its behavior. The more you can identify, the easier it is to visualize the function.
This chapter provides a basic checklist of properties. Many of these should be reviews. I would skim the main terms first, then check the ones you are less familiar with, are new to you, or where your knowledge is rusty.
Smoothness¶
First, you should check whether the function is well-behaved. Look for locations where it might jump suddenly, or where its slope changes instanteneously.
Continuity: A function is continuous if is well defined for all and equals .
In other words, the function has no jumps, or isolated points. It is smooth.
For example, a random variable is continuous if and only if its CDF is a continuous function (see Section 2.3).
The CDF of a discrete random variable always includes jump discontinuities at each where . The example function provided below could be the CDF of a discrete random variable. It is discontinuous:
If you can write down your function, and it doesn’t come in many separate pieces, then it is usually continuous.
Differentiable: A function is differentiable if exists for all . That is, if it has a well-defined slope everywhere.
Functions with kinks, or corners, (e.g. ) may not be differentiable everywhere.
A function is second differentiable if its slope is differentiable (second derivatives exist everywhere).
Almost every function we study in this class will be infinitely differentiable, i.e. all derivatives exist for all relevant .
Not all density functions are differentiable at all . For instance, the density function is a popular model for sparse regression.
Symmetric: A function is even if . A function is odd if .
The names even and odd point to the simplest examples; polynomials. A polynomial is even if all its terms are to an even power. It is odd if all its terms are to an odd power. If all the terms in a polynomial are even powers then the polynomial is an even function, for instance . If all ther terms are odd powers, then the function is odd, for instance or .
A function is symmetric about some axis of symmetry if there exists an such that or . That is, if is even or odd with respect to reflections about .
For example, is an even function with an axis of symmetry at . Often we can recognize axes of symmetry by finding translations of the function that move the axis of symmetry to the origin.
Since distribution functions are nonnegative they are never odd. Mass functions and density functions may be even. Some of the most famous density functions are even. For instance, for is an important model for the distribution of test statistics. Notice, this function is even since it can be expressed as a composition of two functions, an outer function , and an inner function . Then .
Anytime a function can be expressed as a composition of functions, and the innermost function is even, then the whole function is even.
Symmetries are very useful tools for visualization. If you know that a function is symmetric about an axis, then you only need to visualize half of it. The other half is implied by reflection (even), or reflection and negation (odd). The better you get at recognizing symmetries, the faster you will be at visualizing functions.
Bounded: A function is bounded if it lies below some finite upper bound, or above some finite lower bound.
A function is bounded from below if for some . The most important examples in probability are distribution functions, which are bounded below by 0 (are nonnegative).
A function is bounded from above if for some . For example, every PMF and CDF is bounded above by one because PMF’s and CDF’s return chances. PDF’s, in contrast, return densities, and need only integrate to one. So PDF’s need not be bounded above.
Monotonic: A function is monotonic or monotone if it never changes direction.
It may be monotonically increasing ( if ), nondecreasing ( is ), nonincreasing ( if ), or decreasing ( if ). For example, every CDF is monotonically nondecreasing.
A differentiable function is monotonic if its derivative never changes sign.
Every CDF is a monotonically nonincreasing function. The CDF of a continuous random variable is increasing wherever the variable is supported, e.g. has nonzero density.
Convex/Concave: A function is convex if it ``bends upwwards." It is concave if it “bends downwards.”
Formally, a function is convex if the chord from to is never beneath for any between and . It is concave if the chord lies beneath the function between and . In the example shown below, the function is displayed in blue and the chord for arbitrarily selected and is in red.
If the function is second differentiable, it is convex if its second derivative is nonnegative. It is concave if its second derivative is nonpositive. It is strictly convex/concave if its second derivative never changes sign and does not equal zero on any open interval.
In essence, convex functions always curve up so that they lie above their tangent lines, and beneath any chord.
Because density functions, mass functions, and cumulative distribution functions are usually bounded above and below, they are rarely convex or concave for all . Some simple examples, like the Exponential and Pareto distributions from Section 2.4 are convex, but it is more common to see distribution functions that are convex on some intervals and concave on others. The famous “bell curve” is concave about its peak, and convex in its tails. Locations where the curvature of a function changes are called inflection points.
It is very common to see distribution functions whose logarithm is concave, most famously, the normal distributions whose simplest form is . Taking a log returns , whose second derivative is -1 everywhere. More generally, it is common to build distribution functions as a composition of two functions, a concave or convex function on the inside, then a monotonic function that is nonnegative and converges to zero given infinite inputs on the inside. For example, .
Concavity and convexity are important for visualizing functions and are essential properties in optimization. It is much easier to find the peak of a concave function, or the valley of a convex function, than it is to find the peak or valley of a function that is neither concave nor convex. Functions that are strictly concave have, at most, one unique maximizer. As a result, distributions that are constructed as a composition of a concave/convex function inside a monotone function have a single peak. We call distributions with a single peak unimodal since they have a unique mode.
Interactive Function Properties Quiz¶
Run the code cell below to test your knowledge. You should be able to quickly categorize every elementary function listed according to the properties defined above. Practice until this categorization is instinctive.
from utils_week3_functions import show_function_properties
properties = show_function_properties()