Package fastghquad. R topics documented: February 19, 2015



Similar documents
Package PACVB. R topics documented: July 10, Type Package

Lecture 8 : Dynamic Stability

Package ChannelAttribution

Package EstCRM. July 13, 2015

Integration. Topic: Trapezoidal Rule. Major: General Engineering. Author: Autar Kaw, Charlie Barker.

Package MBA. February 19, Index 7. Canopy LIDAR data

Package bigdata. R topics documented: February 19, 2015

Numerical Analysis. Gordon K. Smyth in. Encyclopedia of Biostatistics (ISBN ) Edited by. Peter Armitage and Theodore Colton

Package wordcloud. R topics documented: February 20, 2015

Package tvm. R topics documented: August 21, Type Package Title Time Value of Money Functions Version Author Juan Manuel Truppia

Numerical Analysis An Introduction

Variance Reduction. Pricing American Options. Monte Carlo Option Pricing. Delta and Common Random Numbers

Inner Product Spaces

Marshall-Olkin distributions and portfolio credit risk

AN INTRODUCTION TO NUMERICAL METHODS AND ANALYSIS

NUMERICAL ANALYSIS PROGRAMS

Package zic. September 4, 2015

STA 4273H: Statistical Machine Learning

Package biganalytics

SOLUTIONS. f x = 6x 2 6xy 24x, f y = 3x 2 6y. To find the critical points, we solve

Package missforest. February 20, 2015

Introduction to the Finite Element Method

Probability and Statistics Prof. Dr. Somesh Kumar Department of Mathematics Indian Institute of Technology, Kharagpur

Package hier.part. February 20, Index 11. Goodness of Fit Measures for a Regression Hierarchy

General Framework for an Iterative Solution of Ax b. Jacobi s Method

Introduction to Mobile Robotics Bayes Filter Particle Filter and Monte Carlo Localization

Lecture Notes to Accompany. Scientific Computing An Introductory Survey. by Michael T. Heath. Chapter 10

Package cpm. July 28, 2015

CS Software Engineering for Scientific Computing. Lecture 16: Particle Methods; Homework #4

Operation Count; Numerical Linear Algebra

Bayes and Naïve Bayes. cs534-machine Learning

Package tagcloud. R topics documented: July 3, 2015

Package polynom. R topics documented: June 24, Version 1.3-8

Package benford.analysis

Linear Classification. Volker Tresp Summer 2015

Package MDM. February 19, 2015

INTERPOLATION. Interpolation is a process of finding a formula (often a polynomial) whose graph will pass through a given set of points (x, y).

Chebyshev Expansions

Natural cubic splines

BayesX - Software for Bayesian Inference in Structured Additive Regression

User Guide Thank you for purchasing the DX90

CSCI567 Machine Learning (Fall 2014)

Factoring Cubic Polynomials

Numerical Analysis. Professor Donna Calhoun. Fall 2013 Math 465/565. Office : MG241A Office Hours : Wednesday 10:00-12:00 and 1:00-3:00

POLYNOMIAL HISTOPOLATION, SUPERCONVERGENT DEGREES OF FREEDOM, AND PSEUDOSPECTRAL DISCRETE HODGE OPERATORS

The Convolution Operation

it is easy to see that α = a

Introduction to General and Generalized Linear Models

JUST THE MATHS UNIT NUMBER 1.8. ALGEBRA 8 (Polynomials) A.J.Hobson

Package changepoint. R topics documented: November 9, Type Package Title Methods for Changepoint Detection Version 2.

Linearly Independent Sets and Linearly Dependent Sets

Chapter 20. Vector Spaces and Bases

Non Linear Dependence Structures: a Copula Opinion Approach in Portfolio Optimization

Two Topics in Parametric Integration Applied to Stochastic Simulation in Industrial Engineering

1 Inner Products and Norms on Real Vector Spaces

Package bigrf. February 19, 2015

Stability. Chapter 4. Topics : 1. Basic Concepts. 2. Algebraic Criteria for Linear Systems. 3. Lyapunov Theory with Applications to Linear Systems

(Refer Slide Time: 1:42)

Learning Gaussian process models from big data. Alan Qi Purdue University Joint work with Z. Xu, F. Yan, B. Dai, and Y. Zhu

Sections 2.11 and 5.8

1 Maximum likelihood estimation

Statistics Graduate Courses

Stress Recovery 28 1

The Heat Equation. Lectures INF2320 p. 1/88

Package urltools. October 11, 2015

Influences in low-degree polynomials

Package xtal. December 29, 2015

Centre for Central Banking Studies

Package MFDA. R topics documented: July 2, Version Date Title Model Based Functional Data Analysis

Package retrosheet. April 13, 2015

Computational Assignment 4: Discriminant Analysis

7. LU factorization. factor-solve method. LU factorization. solving Ax = b with A nonsingular. the inverse of a nonsingular matrix

Dynamic Eigenvalues for Scalar Linear Time-Varying Systems

Bayesian Image Super-Resolution

NUMERICAL METHODS TOPICS FOR RESEARCH PAPERS

GEC320 COURSE COMPACT. Four hours per week for 15 weeks (60 hours)

Inner product. Definition of inner product

On using numerical algebraic geometry to find Lyapunov functions of polynomial dynamical systems

The dynamic equation for the angular motion of the wheel is R w F t R w F w ]/ J w

A Coefficient of Variation for Skewed and Heavy-Tailed Insurance Losses. Michael R. Powers[ 1 ] Temple University and Tsinghua University

PUTNAM TRAINING POLYNOMIALS. Exercises 1. Find a polynomial with integral coefficients whose zeros include

Linear Algebra Notes for Marsden and Tromba Vector Calculus

Big Data, Statistics, and the Internet

Extrinsic geometric flows

Monte Carlo Simulation

MTH 437/537 Introduction to Numerical Analysis I Fall 2015

Gaussian Processes in Machine Learning

Orthogonal Diagonalization of Symmetric Matrices

Variational approach to restore point-like and curve-like singularities in imaging

The Characteristic Polynomial

Transcription:

Package fastghquad February 19, 2015 Type Package Title Fast Rcpp implementation of Gauss-Hermite quadrature Version 0.2 Date 2014-08-13 Author Alexander W Blocker Maintainer Fast, numerically-stable Gauss-Hermite quadrature License MIT + file LICENSE LazyLoad yes URL https://github.com/awblocker/fastghquad Depends Rcpp (>= 0.11.0) LinkingTo Rcpp NeedsCompilation yes Repository CRAN Date/Publication 2014-08-14 07:11:15 R topics documented: fastghquad-package.................................... 2 aghquad........................................... 3 evalhermitepoly...................................... 4 findpolyroots........................................ 5 gausshermitedata...................................... 6 ghquad........................................... 7 hermitepolycoef...................................... 8 Index 10 1

2 fastghquad-package fastghquad-package A package for fast, numerically-stable computation of Gauss-Hermite quadrature rules Details This package provides functions to compute Gauss-Hermite quadrature rules very quickly with a higher degree of numerical stability (tested up to 2000 nodes). It also provides function for adaptive Gauss-Hermite quadrature, extending Laplace approximations (as in Liu & Pierce 1994). Package: Type: License: LazyLoad: fastghquad Package MIT yes Alexander W Blocker Maintainer: References Golub, G. H. and Welsch, J. H. (1969). Calculation of Gauss Quadrature Rules. Mathematics of Computation 23 (106): 221-230. Liu, Q. and Pierce, D. A. (1994). A Note on Gauss-Hermite Quadrature. Biometrika, 81(3) 624-629. gausshermitedata, aghquad, ghquad Examples # Get quadrature rule rule <- gausshermitedata(1000) # Find a normalizing constant g <- function(x) 1/(1+x^2/10)^(11/2) # t distribution with 10 df aghquad(g, 0, 1.1, rule) # actual is 1/dt(0,10) # Find an expectation

aghquad 3 g <- function(x) x^2*dt(x,10) # t distribution with 10 df aghquad(g, 0, 1.1, rule) # actual is 1.25 aghquad Adaptive Gauss-Hermite quadrature using Laplace approximation Convenience function for integration of a scalar function g based upon its Laplace approximation. aghquad(g, muhat, sigmahat, rule,...) g muhat sigmahat rule Details Function to integrate with respect to first (scalar) argument Mode for Laplace approximation Scale for Laplace approximation (sqrt(-1/h), where H is the second derivative of g at muhat) Gauss-Hermite quadrature rule to use, as produced by gausshermitedata... Additional arguments for g This function approximates g(x) dx using the method of Liu & Pierce (1994). This technique uses a Gaussian approximation of g (or the distribution component of g, if an expectation is desired) to "focus" quadrature around the high-density region of the distribution. Formally, it evaluates: 2ˆσ w i exp(x 2 i )g(ˆµ + 2 where x and w come from the given rule. i ˆσx i ) This method can, in many cases (where the Gaussian approximation is reasonably good), achieve better results with 10-100 quadrature points than with 1e6 or more draws for Monte Carlo integration. It is particularly useful for obtaining marginal likelihoods (or posteriors) in hierarchical and multilevel models where conditional independence allows for unidimensional integration, adaptive Gauss-Hermite quadrature is often extremely effective. Numeric (scalar) with approximation integral of g from -Inf to Inf.

4 evalhermitepoly References Liu, Q. and Pierce, D. A. (1994). A Note on Gauss-Hermite Quadrature. Biometrika, 81(3) 624-629. gausshermitedata, ghquad Examples # Get quadrature rules rule10 <- gausshermitedata(10) rule100 <- gausshermitedata(100) # Estimating normalizing constants g <- function(x) 1/(1+x^2/10)^(11/2) # t distribution with 10 df aghquad(g, 0, 1.1, rule10) aghquad(g, 0, 1.1, rule100) # actual is 1/dt(0,10) # Can work well even when the approximation is not exact g <- function(x) exp(-abs(x)) # Laplace distribution aghquad(g, 0, 2, rule10) aghquad(g, 0, 2, rule100) # actual is 2 # Estimating expectations # Variances for the previous two distributions g <- function(x) x^2*dt(x,10) # t distribution with 10 df aghquad(g, 0, 1.1, rule10) aghquad(g, 0, 1.1, rule100) # actual is 1.25 # Can work well even when the approximation is not exact g <- function(x) x^2*exp(-abs(x))/2 # Laplace distribution aghquad(g, 0, 2, rule10) aghquad(g, 0, 2, rule100) # actual is 2 evalhermitepoly Evaluate Hermite polynomial at given location

findpolyroots 5 Evaluate Hermite polynomial of given degree at given location. This function is provided for demonstration/teaching purposes; this method is not used by gausshermitedata. It is numerically unstable for high-degree polynomials. evalhermitepoly(x, n) x n Vector of location(s) at which polynomial will be evaluated Degree of Hermite polynomial to compute Vector of length(x) values of Hermite polynomial gausshermitedata, aghquad, ghquad findpolyroots Find real parts of roots of polynomial Finds real parts of polynomial s roots via eigendecomposition of companion matrix. This method is not used by gausshermitedata. Only the real parts of each root are retained; this can be useful if the polynomial is known a priori to have all roots real. findpolyroots(c) c Coefficients of polynomial Numeric vector containing the real parts of the roots of the polynomial defined by c

6 gausshermitedata gausshermitedata, aghquad, ghquad gausshermitedata Compute Gauss-Hermite quadrature rule Computes Gauss-Hermite quadrature rule of requested order using Golub-Welsch algorithm. Returns result in list consisting of two entries: x, for nodes, and w, for quadrature weights. This is very fast and numerically stable, using the Golub-Welsch algorithm with specialized eigendecomposition (symmetric tridiagonal) LAPACK routines. It can handle quadrature of order 1000+. gausshermitedata(n) n Order of Gauss-Hermite rule to compute (number of nodes) Details This function computes the Gauss-Hermite rule of order n using the Golub-Welsch algorithm. All of the actual computation is performed in C/C++ and FORTRAN (via LAPACK). It is numericallystable and extremely memory-efficient for rules of order 1000+. A list containing: x w the n node positions for the requested rule the w quadrature weights for the requested rule References Golub, G. H. and Welsch, J. H. (1969). Calculation of Gauss Quadrature Rules. Mathematics of Computation 23 (106): 221-230 Liu, Q. and Pierce, D. A. (1994). A Note on Gauss-Hermite Quadrature. Biometrika, 81(3) 624-629.

ghquad 7 aghquad, ghquad ghquad Convenience function for Gauss-Hermite quadrature Convenience function for evaluation of Gauss-Hermite quadrature ghquad(f, rule,...) f rule Details Function to integrate with respect to first (scalar) argument; this does not include the weight function exp(-x^2) Gauss-Hermite quadrature rule to use, as produced by gausshermitedata... Additional arguments for f This function performs classical unidimensional Gauss-Hermite quadrature with the function f using the rule provided; that is, it approximates f(x) exp( x 2 ) dx by evaluating w i f(x i ) i Numeric (scalar) with approximation integral of f(x)*exp(-x^2) from -Inf to Inf. References Golub, G. H. and Welsch, J. H. (1969). Calculation of Gauss Quadrature Rules. Mathematics of Computation 23 (106): 221-230. Liu, Q. and Pierce, D. A. (1994). A Note on Gauss-Hermite Quadrature. Biometrika, 81(3) 624-629.

8 hermitepolycoef gausshermitedata, ghquad Examples # Get quadrature rules rule10 <- gausshermitedata(10) rule100 <- gausshermitedata(100) # Check that rule is implemented correctly f <- function(x) rep(1,length(x)) if (!istrue(all.equal(sqrt(pi), ghquad(f, rule10), ghquad(f, rule100)))) { print(ghquad(f, rule10)) print(ghquad(f, rule100)) } # These should be 1.772454 f <- function(x) x if (!istrue(all.equal(0.0, ghquad(f, rule10), ghquad(f, rule100)))) { print(ghquad(f, rule10)) print(ghquad(f, rule100)) } # These should be zero hermitepolycoef Get coefficient of Hermite polynomial Calculate coefficients of Hermite polynomial using recursion relation. This function is provided for demonstration/teaching purposes; this method is not used by gausshermitedata. It is numerically unstable for high-degree polynomials. hermitepolycoef(n) n Degree of Hermite polynomial to compute Vector of (n+1) coefficients from requested polynomial

hermitepolycoef 9 gausshermitedata, aghquad, ghquad

Index Topic math aghquad, 3 evalhermitepoly, 4 findpolyroots, 5 gausshermitedata, 6 ghquad, 7 hermitepolycoef, 8 Topic package fastghquad-package, 2 aghquad, 2, 3, 5 7, 9 evalhermitepoly, 4 fastghquad (fastghquad-package), 2 fastghquad-package, 2 findpolyroots, 5 gausshermitedata, 2 6, 6, 7 9 ghquad, 2, 4 7, 7, 8, 9 hermitepolycoef, 8 10