Skip to content

Instantly share code, notes, and snippets.

@TonyLadson
Created March 25, 2015 03:09
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/08d6a1834d6f395c725e to your computer and use it in GitHub Desktop.
Save TonyLadson/08d6a1834d6f395c725e to your computer and use it in GitHub Desktop.
The table of delta values is taken from Table 2.4, Book IV, Section 2 of Australian Rainfall and Runoff third edition
##########################################################################################################################
#
# Delta values
#
# tony.ladson at gmail.com
# 11 March 2015
#
# Used to determine confidence intervals for the Log Pearson III distribution
# The table of delta values is taken from Table 2.4, Book IV, Section 2 of Australian Rainfall and Runoff third edition.
# Confidence interval calculations are based on
# Kite, G.W. (1977) Frequency and Risk Analysis in Hydrology. Water Resources Publications. Fort Collins, Colorado.
##########################################################################################################################
DeltaTable <- function(g, aep){
require(e1071)
if(abs(g) > 3.9) stop('g must be in the range -3.9 to +3.9')
if(aep < 0.002 | aep > 0.998) stop('AEP must be in the range 0.002 to 0.998')
if(length(aep) > 1 | length(g) >1) stop('g and AEP cannot have length greater than 1')
delta.values <- vector('numeric', length=600) # allocate space
# load in values from Delta table
delta.values <- c(2.6102, 2.6102, 2.6102, 2.6101, 2.6082, 2.5891, 2.4087, 0.5363, 4.4886, 4.7005, 5.1756, 9.9653, 15.4073, 22.4853, 31.9077,
2.6298, 2.6298, 2.6297, 2.6296, 2.6265, 2.5997, 2.3786, 0.6153, 4.3337, 4.4965, 5.0813, 9.7617, 15.0670, 21.5008, 31.2357,
2.6509, 2.6509, 2.6509, 2.6506, 2.6457, 2.6087, 2.3411, 0.7059, 4.1996, 4.2898, 4.9937, 9.6927, 14.9442, 20.5459, 30.531,
2.6738, 2.6738, 2.6737, 2.6732, 2.6656, 2.6152, 2.2950, 0.8026, 4.0442, 4.1146, 4.9139, 9.4693, 14.5732, 20.5011, 28.9995,
2.6986, 2.6986, 2.6984, 2.6976, 2.6860, 2.6184, 2.2397, 0.9005, 3.8980, 3.9376, 4.8401, 9.3747, 14.4052, 19.8360, 28.2778,
2.7256, 2.7255, 2.7253, 2.7238, 2.7063, 2.6172, 2.1754, 0.9923, 3.7436, 3.7616, 4.7704, 9.1998, 13.8058, 19.1711, 26.8197,
2.7550, 2.7549, 2.7544, 2.7518, 2.7261, 2.6105, 2.1009, 1.0805, 3.5876, 3.6138, 4.7085, 9.0794, 13.6041, 18.5073, 26.0872,
2.7871, 2.7869, 2.7860, 2.7817, 2.7446, 2.5970, 2.0168, 1.1610, 3.4364, 3.4732, 4.6496, 8.8832, 13.1947, 18.0860, 25.3332,
2.8222, 2.8219, 2.8203, 2.8133, 2.7608, 2.5755, 1.9239, 1.2354, 3.2848, 3.3456, 4.5919, 8.7384, 12.7808, 17.6424, 23.9653,
2.8608, 2.8601, 2.8573, 2.8463, 2.7734, 2.5445, 1.8219, 1.2993, 3.1389, 3.2214, 4.5339, 8.5812, 12.4464, 16.9623, 23.7706,
2.9033, 2.9018, 2.8971, 2.8801, 2.7809, 2.5030, 1.7128, 1.3522, 2.9941, 3.1105, 4.4657, 8.3562, 12.1008, 16.2880, 21.9173,
2.9501, 2.9474, 2.9395, 2.9138, 2.7818, 2.4504, 1.5973, 1.3978, 2.8512, 3.0116, 4.4125, 8.1779, 11.8204, 15.6206, 21.6578,
3.0016, 2.9968, 2.9840, 2.9462, 2.7741, 2.3857, 1.4774, 1.4336, 2.7204, 2.9231, 4.3474, 7.9380, 11.3809, 14.9608, 20.4048,
3.0585, 3.0500, 3.0299, 2.9758, 2.7564, 2.3087, 1.3554, 1.4576, 2.5881, 2.8437, 4.2881, 7.7415, 11.0090, 14.4777, 19.6345,
3.1209, 3.1067, 3.0760, 3.0007, 2.7262, 2.2196, 1.2337, 1.4743, 2.4684, 2.7707, 4.2149, 7.5360, 10.6308, 13.9830, 18.458,
3.1891, 3.1660, 3.1207, 3.0184, 2.6830, 2.1195, 1.1161, 1.4840, 2.3491, 2.7049, 4.1568, 7.3222, 10.1879, 13.4787, 17.7047,
3.2627, 3.2263, 3.1616, 3.0265, 2.6255, 2.0099, 1.0035, 1.4831, 2.2425, 2.6445, 4.0740, 7.1011, 9.8604, 12.9668, 16.949,
3.3412, 3.2859, 3.1956, 3.0226, 2.5533, 1.8922, 0.9008, 1.4753, 2.1412, 2.5893, 3.9961, 6.8735, 9.4707, 12.1889, 16.1934,
3.4223, 3.3421, 3.2200, 3.0033, 2.4664, 1.7681, 0.8124, 1.4622, 2.0519, 2.5378, 3.9129, 6.6403, 9.0795, 11.8061, 15.4403,
3.5041, 3.3900, 3.2312, 2.9675, 2.3657, 1.6414, 0.7390, 1.4439, 1.9670, 2.4886, 3.8348, 6.3943, 8.6881, 11.1781, 14.692,
3.5834, 3.4275, 3.2263, 2.9143, 2.2542, 1.5162, 0.6862, 1.4208, 1.8911, 2.4416, 3.7425, 6.1755, 8.2977, 10.5657, 13.9507,
3.6548, 3.4493, 3.2024, 2.8425, 2.1332, 1.3938, 0.6540, 1.3947, 1.8227, 2.3952, 3.6483, 5.9384, 7.9095, 10.0671, 13.2189,
3.7134, 3.4519, 3.1581, 2.7533, 2.0063, 1.2784, 0.6419, 1.3663, 1.7614, 2.3489, 3.5501, 5.7001, 7.5625, 9.5713, 12.2786,
3.7539, 3.4325, 3.0928, 2.6488, 1.8772, 1.1735, 0.6471, 1.3366, 1.7065, 2.3022, 3.4482, 5.4613, 7.1794, 8.9957, 11.5884,
3.7717, 3.3897, 3.0080, 2.5321, 1.7499, 1.0823, 0.6656, 1.3065, 1.6574, 2.2544, 3.3430, 5.2228, 6.8350, 8.5168, 10.9126,
3.7635, 3.3238, 2.9061, 2.4073, 1.6284, 1.0079, 0.6933, 1.2768, 1.6131, 2.2052, 3.2347, 4.9854, 6.4618, 8.1186, 10.253,
3.7285, 3.2374, 2.7915, 2.2792, 1.5171, 0.9522, 0.7265, 1.2482, 1.5730, 2.1544, 3.1238, 4.7498, 6.1543, 7.5835, 9.6113,
3.6683, 3.1348, 2.6695, 2.1532, 1.4198, 0.9164, 0.7626, 1.2213, 1.5361, 2.1018, 3.0109, 4.5169, 5.7936, 7.1321, 8.9892,
3.5872, 3.0220, 2.5463, 2.0350, 1.3401, 0.9000, 0.7998, 1.1966, 1.5019, 2.0475, 2.8964, 4.2874, 5.4553, 6.6928, 8.3881,
3.4922, 2.9065, 2.4287, 1.9299, 1.2807, 0.9015, 0.8370, 1.1742, 1.4696, 1.9913, 2.7808, 4.0620, 5.1499, 6.2669, 7.8094,
3.3919, 2.7963, 2.3238, 1.8434, 1.2434, 0.9182, 0.8736, 1.1544, 1.4387, 1.9335, 2.6647, 3.8416, 4.8288, 5.8817, 7.3749,
3.2967, 2.7001, 2.2381, 1.7797, 1.2286, 0.9471, 0.9093, 1.1372, 1.4086, 1.8741, 2.5487, 3.6268, 4.5181, 5.4846, 6.7804,
3.2170, 2.6258, 2.1777, 1.7422, 1.2352, 0.9856, 0.9441, 1.1226, 1.3790, 1.8135, 2.4332, 3.4184, 4.2506, 5.1044, 6.2723,
3.1634, 2.5809, 2.1471, 1.7328, 1.2613, 1.0311, 0.9781, 1.1105, 1.3496, 1.7519, 2.3189, 3.2169, 3.9620, 4.7655, 5.8442,
3.1449, 2.5710, 2.1493, 1.7516, 1.3042, 1.0818, 1.0113, 1.1007, 1.3202, 1.6895, 2.2062, 3.0232, 3.6961, 4.3972, 5.3892,
3.1156, 2.5652, 2.1638, 1.7867, 1.3600, 1.1365, 1.0416, 1.0918, 1.2905, 1.6227, 2.0915, 2.8423, 3.4724, 4.1386, 5.0602,
3.1997, 2.6434, 2.2394, 1.8607, 1.4292, 1.1937, 1.0744, 1.0866, 1.2609, 1.5610, 1.9852, 2.6656, 3.2365, 3.8397, 4.6726,
3.3323, 2.7599, 2.3451, 1.9557, 1.5074, 1.2529, 1.1067, 1.0830, 1.2309, 1.4989, 1.8815, 2.4986, 3.0175, 3.5656, 4.3219,
3.5128, 2.9129, 2.4782, 2.0692, 1.5930, 1.3133, 1.1385, 1.0808, 1.2006, 1.4367, 1.7810, 2.3425, 2.8168, 3.3183, 4.0101,
3.7212, 3.0983, 2.6363, 2.1988, 1.6845, 1.3748, 1.1698, 1.0801, 1.1698, 1.3748, 1.6845, 2.1988, 2.6363, 3.0983, 3.7212)
delta.table <- matrix(delta.values, nrow=40, ncol=15, byrow=TRUE)
delta.table <- delta.table[40:1,15:1] # we need to re-order the data so its from lowest to highest value in each dimension
my.rownames <- seq(0,3.9,0.1)
my.colnames <- rev(c(0.998, 0.995, 0.990, 0.980, 0.950, 0.900, 0.800, 0.500, 0.200, 0.100, 0.050, 0.020, 0.010, 0.005, 0.002))
dimnames(delta.table) <- list(my.rownames, my.colnames) # name the rows and columns
if(g < 0) { # for negative g we set g positive and take 1 - aep
g <- abs(g)
aep <- 1 - aep
}
interpolate(c(g, aep), delta.table)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment