Skip to content

Instantly share code, notes, and snippets.

@TonyLadson
Created March 25, 2015 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TonyLadson/acdbdc1d835a5d12c2fd to your computer and use it in GitHub Desktop.
Save TonyLadson/acdbdc1d835a5d12c2fd to your computer and use it in GitHub Desktop.
Function to return delta as used to estimate confidence intervals for flood frequency analysis
# Function to return delta as used to estimate
# confidence intervals for flood frequency analysis
# Usage
# Delta(g, aep)
#
# g = skewness
# aep = Annual exceedance probability
#
# Implementing equation 9-54 from Kite (2004)
# Frequency and risk analysis in hydrology. Water Resources Publications
# and Equation 2.17 Book IV Australian Rainfall and Runoff
Delta <- function(g, aep){
require(lmomco)
require(numDeriv)
Ky_Qp3 <- function(g, aep){
# Return the quantile of the Pearson III distribution given
# skewness of g, and annual exceedance probability, aep
param <- vec2par(c(0,1,g), type='pe3')
quape3(1 - aep, param)
}
K <- Ky_Qp3(g, aep)
dK <- grad(Ky_Qp3, g, method="Richardson", aep = aep)
sqrt(1 + K*g + 0.5*(K^2)*(0.75*(g^2) + 1) + 3*K*dK*(g + 0.25*g^3) + 3*(dK^2)*(2 + 3*g^2 + (5/8)*g^4))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment