Re: MORE: Statistics`ContinousDistributions` (integrating over a UniformDistribution)
- To: mathgroup at smc.vnet.net
- Subject: [mg9309] Re: [mg9252] MORE: Statistics`ContinousDistributions` (integrating over a UniformDistribution)
- From: David Withoff <withoff>
- Date: Mon, 27 Oct 1997 02:47:22 -0500
- Sender: owner-wri-mathgroup at wolfram.com
> More on this.... > > I have just found out that putting the limits {x, 0, Pi} doesn't work > either!!! > > When I try to calculate the MeanDist[] of the function Sin[x] > > MeanDist[Sin[x]], I get a similar result whether or not I set the > limits to {x, 0, Pi}. > > This puzzles me greatly since in the interval {0,Pi} the integrand > should merely be "Sin[x] (1/Pi)". Why can't Mathematica deal with it? > > ------------- for review ----------- > > ><<Statistics`ContinuousDistributions` > > > >p[x_] := PDF[UniformDistribution[0,Pi],x] > > > >MeanDist[f_] := Integrate[ f p[x], {x, 0, Pi}] > > MeanDist[ Sin[x] ] Doesn't give 2/Pi like I'd expect. (and I > don't even like forcing the limits to {0,Pi}... much better to have > {-infinity,infinity} > > > >=============================================================== > > > ><<Statistics`ContinuousDistributions` > > > >p[x_] := PDF[UniformDistribution[0,Pi],x] > > > >MeanDist[f_] := Integrate[ f p[x], {x, -Infinity, Infinity}] > > > >(* which gives *) > > > >Integrate::idiv: Integral of (x(Sign[x] - Sign[-Pi+x]))/(2 Pi) does not > >converge on {-Infinity, Infinity}. > >Integrate::idiv: Integral of x (Sign[x] - Sign[-Pi+x]) does not converge on > >{-Infinity, Infinity}. > > > >Integrate[ x (Sign[x] - Sign[-Pi + x])/(2 Pi), {x, -Infinity, Infinity}] > > > >=============================================================== > > > >** again I'm not looking for the answer, I realize for this problem I could > >just put in the limits {x, 0, Pi} and everything is fine.... but would like > >to keep the function MeanDist[] general. If you don't mind changing the representation of the uniform distribution, you may be able to compute some of these integrals like this: In[1]:= Needs["Calculus`DiracDelta`"] In[2]:= p[x_] = UnitStep[x] - UnitStep[-Pi + x] ; In[3]:= Integrate[x p[x], {x, -Infinity, Infinity}] 2 Pi Out[3]= --- 2 In[4]:= Integrate[Sin[x] p[x], {x, 0, Pi}] Out[4]= 2 In general, the only way to do these integrals will be for either you or the computer to figure out how to break them up into pieces. This task is easier for a human mathematician than it is for the computer. There aren't any systematic algorithms for breaking up integrals, so rules rules have to be added for each individual case. Getting what you want may be a matter of exploring to find out which cases have been programmed, or programming them yourself. Since it is necessary to figure out how to break up the integral even if it turns out that the entire range of integration falls within one continuous piece, the integration from -Infinity to Infinity will involve much of the same work as integration from 0 to Pi. Dave Withoff Wolfram Research