Drexel dragonThe Math ForumDonate to the Math Forum

Ask Dr. Math - Questions and Answers from our Archives
Associated Topics || Dr. Math Home || Search Dr. Math

Cosine of a Uniform Random Variable

Date: 05/31/2005 at 10:08:47
From: Maurice
Subject: Cosine of a uniform random variable

Given a uniformly distributed random variable between [0,pi/2], I want
to know the cosine of this variable.  I already know the answer, and 
it is 2/pi.  The problem is, I don't know WHY this is true.  I can 
easily simulate the problem to verify the answer, but I have found no 
clues on how to solve it.

I find it very strange that pi occurs in the result of a cosine.  I'm
quite good at math, but not at statistics.  Perhaps I should take some
integral somewhere, I just don't know.  I searched half the Internet
but could not even find a lead that got me started.

The problem originates from computing the average lighting 
contribution.  Given the fact that gradients are uniformly 
distributed, the dot product of this random vector and another, 
constant vector can be modeled as the cosine of a uniform random 
variable between [0,pi/2].

Date: 05/31/2005 at 12:37:59
From: Doctor Douglas
Subject: Re: Cosine of a uniform random variable

Hi, Maurice.

Yes, you should evaluate two integrals to find the expected value of a 
function f(x) over a distribution p(x):

           Integral{a,b} f(x) p(x) dx
  <f(x)> = --------------------------
             Integral{a,b} p(x) dx

In your case f(x) = cos(x), p(x) = 1 [p is uniform, independent of x], 
and the limits of integration are a=0 and b=pi/2.  The top integral 
leads to sin(x) evaluated between 0 and pi/2, which reduces to 1-0 = 
1.  The bottom integral is just b-a, which is pi/2.  And finally the 
average value of f(x) is just the ratio of these two quantities, which 
is 1/(pi/2) = 2/pi, as you already know.

This equation above is essentially the definition of an expectation
taken over a distribution, and you can see that it is kind of like
a weighted average (each value of f is weighted by the strength of the 
distribution p at that particular value of x).  You must divide, or 
"normalize" the result by the total amount of p, which explains why we 
have the integral in the denominator.  If we had set things up such 
that Integral{a,b}p(x)dx = 1, then p would already have been 
normalized.  To accomplish this we would have had to set p(x)=2/pi
for 0 < x < pi/2 (this uniform distribution is now normalized). 

Note that you can use the above equation for whatever f and p you like
[for example, try f(x) = cos^2(x) and a uniform distribution p on the
interval between 0 and 2*pi, or 0 and pi].

Here are some other answers in our archives that deal with closely
related topics:

  Average Radial Distance of Points within a Circle

  Monte Carlo Approximation of Pi

- Doctor Douglas, The Math Forum
Associated Topics:
College Statistics

Search the Dr. Math Library:

Find items containing (put spaces between keywords):
Click only once for faster results:

[ Choose "whole words" when searching for a word like age.]

all keywords, in any order at least one, that exact phrase
parts of words whole words

Submit your own question to Dr. Math

[Privacy Policy] [Terms of Use]

Math Forum Home || Math Library || Quick Reference || Math Forum Search

Ask Dr. MathTM
© 1994- The Math Forum at NCTM. All rights reserved.