On 10/15/2013 5:37 PM, Marino David wrote:
> Hi Spencer:
>
> Thanks for your interpretation again and again.  Your statement does 
> enable me to have a good understanding of Gaussian quadrature.
>
> This sos package you recommended is greatly powerful. From now on, I 
> will use the sos package to find something helpful before I do some 
> research.
>
> Yes, I want to compute the expection of functions whos variables 
> follow common distriubtions (e.g. F, t, Beta, Gamma, etc.). Via 
> searching referrences, I know that Gaussian quadrature  based 
> on orthogonal polynomials is fast method for integration.


       Often, the most expensive part of any data analysis is the time 
of the person doing it.  For that reason, it's often wise to first try 
the quickest thing available.  Just for fun, I performed the following 
tests on the F distribution:


f. <- Fd(1,1)
sinF <- sin(f.)
E(sinF)
# 0.2093619


       This didn't work for round(sinF).  For that, we can try the 
following:


rf. <- r(sinF)(10000)
mean(round(rf.))
# 0.197


       If I were only doing this once, I wouldn't mess with quadrature.  
If the options like "integrate" or the above take too much compute time, 
then I'll consider other options, like numerical integration with 
quadrature.  However, orthogonal polynomials for a continuous 
distribution won't work properly with a discontinuous transformation 
like round ;-)


       Hope this helps.
       Spencer


> David
>
>
> 2013/10/14 Spencer Graves <spencer.gra...@structuremonitoring.com 
> <mailto:spencer.gra...@structuremonitoring.com>>
>
>     David:
>
>
>           What you have is close, but I perceive some problems:
>
>
>                 integral{from -Inf to Inf of f(x)t(x)dx} =
>     integral{from 0 to Inf of (f(-x)+f(x))t(x)dx}, because Student's t
>     distribution is symmetric.
>
>
>           Now do the change of variables x = sqrt(z), so dx =
>     0.5*dz/sqrt(z).  Then t(x)dx = 0.5*t(sqrt(z))dz/sqrt(z).  Play
>     with this last expression a bit, and you should get it into the
>     form of g(z)dz, where g(z) = the density for the F distribution.
>
>
>           Next transform the F distribution to a beta distribution on
>     [0, 1], NOT a beta distribution on [-1, 1].  There are Jacobi
>     polynomials on [0, 1] you can use.  Or further transform the
>     interval [0, 1] to [-1, 1].
>
>
>           Did you look at the literature search results I sent you
>     using findFn{sos}?  When I need to do something new in statistics,
>     the first thing I do is a literature search like I described,
>     ending with using the installPackages and writeFindFn2xls
>     functions, as described in the sos vignette.  That rarely takes
>     more than a minute or two.  The writeFindFn2xls function should
>     create an Excel file in your working directory, which you can find
>     with getwd().  Open that.  The first sheet is a summary of the
>     different packages.  This gives you a list of different packages. 
>     You can then use that to prioritize your further study.
>
>
>           Two more comments:
>
>
>                 1.  It is conceptually quite simple to write an
>     algorithm to compute polynomials that are orthonormal relative to
>     any distribution.  The Wikipedia article on "Orthogonal
>     polynomials" gives a set of linear equations that must be solved
>     to create them.
>
>
>                 2.  Why do you want orthogonal polynomials? To obtain
>     a very fast algorithm for computing the expected values of a
>     certain class of functions?  If no, have you considered doing
>     without orthogonal polynomials and just computing the expected
>     value of whatever function you want using the distr package to
>     compute the distribution of f(X) and E{distrEx} to compute the
>     expected value?
>
>
>           Best Wishes,
>           Spencer
>
>
>     p.s.  Could you please post a summary of this exchange to R-help,
>     so someone else with a similar question a year from now can find
>     it?  Thanks.
>
>
>     On 10/13/2013 10:12 PM, Marino David wrote:
>>     Hi Spencer:
>>
>>     I still have trouble in understanding your response to email
>>     about Gaussian quadrature. I tried to describe it in detail. See
>>     attachment.
>>
>>     Thank you!
>>
>>     David
>
>
>     -- 
>     Spencer Graves, PE, PhD
>     President and Chief Technology Officer
>     Structure Inspection and Monitoring, Inc.
>     751 Emerson Ct.
>     San José, CA 95126
>     ph:408-655-4567  <tel:408-655-4567>
>     web:www.structuremonitoring.com  <http://www.structuremonitoring.com>
>
>


-- 
Spencer Graves, PE, PhD
President and Chief Technology Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567
web:  www.structuremonitoring.com


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to