Example River Wheaton

The data consits of 72 exceedances of flood peaks in \(m^3s^{1}\) fo the Wheaton River near Carcross in Xukon Terrtory, Canda. The 72 exceedances, for the years 1958 to 1984, are rounded to one decimal place. This data set is commonly used in hydrology for model testing.

[1]:
import findthetail.ftt as ftt
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
[2]:
# disable warning to keep the output clean
# the warning result form divergences in the logarithms in the test statistics
np.warnings.filterwarnings('ignore')

Load data

[3]:
data1 = pd.read_excel('data/river_wheaton_data.xlsx', index_col='Position')

Load data into model and run analyse

[4]:
# instanciate the Ftt (Find the tail) class with data,
# number of mc steps, a name for the report
# and the number of threads to use for the montecarlo simulation
mod = ftt.Ftt(data1['x'].values, mc_steps=500, data_name='River Wheaton', threads=2)
# additional quantils can be calculated by giving the run_analysis
# function an array with specific p-values
mod.run_analysis(p_values=np.array([0.95, 0.99, 0.9999]))
Runnig fit
Running Montecarlo simulation
Calculating q and cvar
Generating plots

Take a look at the p-value.

[5]:
mod.p_value_a2
[5]:
0.678

The error of the p-value is given by \(\sigma = \frac{1}{\sqrt{\#MC_{steps}}}\)

[6]:
mod.mc_error
[6]:
0.03162277660168379

Using the run_montecarlo_simulation function the p-value can be calculated with a smaller error. The threads argument specifies the number of threads to use for the simulation. With a value of 4 for threads and 1000 mc_steps 4000 additional montecarlo points will be generated.

[7]:
mod.run_montecarlo_simulation(mc_steps=1000, threads=4)
        999/1000
[8]:
mod.mc_error
[8]:
0.01414213562373095

Generate report

[9]:
mod.report_html()

The report can be found here