Last active
March 23, 2022 11:54
-
-
Save taruma/ffa77e6f50a19fa5d05ab10e27d3266a to your computer and use it in GitHub Desktop.
taruma_hk127_gumbel.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "nbformat": 4, | |
| "nbformat_minor": 0, | |
| "metadata": { | |
| "colab": { | |
| "name": "taruma_hk127_gumbel.ipynb", | |
| "provenance": [], | |
| "collapsed_sections": [], | |
| "authorship_tag": "ABX9TyNr9g52UfD6yK+ycBgaTLhs", | |
| "include_colab_link": true | |
| }, | |
| "kernelspec": { | |
| "name": "python3", | |
| "display_name": "Python 3" | |
| }, | |
| "language_info": { | |
| "name": "python" | |
| } | |
| }, | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "metadata": { | |
| "id": "view-in-github", | |
| "colab_type": "text" | |
| }, | |
| "source": [ | |
| "<a href=\"https://colab.research.google.com/gist/taruma/ffa77e6f50a19fa5d05ab10e27d3266a/taruma_hk127_gumbel.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "Berdasarkan isu [#127](https://github.com/hidrokit/hidrokit/issues/127): **anfrek: Gumbel**\n", | |
| "\n", | |
| "Referensi Isu:\n", | |
| "- Soetopo, W., Montarcih, L., Press, U. B., & Media, U. (2017). Rekayasa Statistika untuk Teknik Pengairan. Universitas Brawijaya Press. https://books.google.co.id/books?id=TzVTDwAAQBAJ\n", | |
| "- Limantara, L. (2018). Rekayasa Hidrologi.\n", | |
| "- Soewarno. (1995). hidrologi: Aplikasi Metode Statistik untuk Analisa Data.NOVA.\n", | |
| "- Al-Mashidani, G., Lal, P. B. B., & Mujda, M. F. (1978). A simple version of Gumbel’s method for flood estimation / Version simplifiée de la méthode de Gumbel pour l’estimation des crues. Hydrological Sciences Bulletin, 23(3), 373–380. https://doi.org/10.1080/02626667809491810\n", | |
| "- https://github.com/anyarcherty/Seattle_Rainfall/blob/master/Seattle%20Weather.ipynb\n", | |
| "- Gumbel, E. J. (2012). Statistics of Extremes. Dover Publications. https://books.google.co.id/books?id=ku18nuinb4wC\n", | |
| "\n", | |
| "\n", | |
| "Deskripsi Isu:\n", | |
| "- Mencari nilai ekstrim dengan kala ulang tertentu. Penerapan ini bisa digunakan untuk hujan rancangan atau debit banjir rancangan. \n", | |
| "\n", | |
| "Diskusi Isu:\n", | |
| "- [#156](https://github.com/hidrokit/hidrokit/discussions/156) - Bagaimana menghitung periode ulang distribusi (analisis frekuensi) tanpa melihat tabel?\n", | |
| "\n", | |
| "Strategi:\n", | |
| "- Akan mengikuti fungsi log pearson [#126](https://github.com/hidrokit/hidrokit/issues/126) seperti pada [manual](https://gist.github.com/taruma/60725ffca91dc6e741daee9a738a978b)." | |
| ], | |
| "metadata": { | |
| "id": "Q_EwdXLx2Gu_" | |
| } | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "# PERSIAPAN DAN DATASET" | |
| ], | |
| "metadata": { | |
| "id": "VKZXpflFrwHy" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "metadata": { | |
| "id": "KMjOQ2iD15oh" | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "import numpy as np\n", | |
| "import pandas as pd\n", | |
| "from scipy import stats" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "# contoh data diambil dari buku\n", | |
| "# hidrologi: Aplikasi Metode Statistik untuk Analisa Data hal. 125\n", | |
| "\n", | |
| "_DEBIT = [\n", | |
| " 244, 217, 285, 261, 295, 252, 275, 204, 208, 194, 256, 207, 354, 445, \n", | |
| " 350, 336, 328, 269, 323, 364, 247, 290, 302, 301, 284, 276, 261, 303, \n", | |
| " 335, 320\n", | |
| "]\n", | |
| "\n", | |
| "_TAHUN = list(range(1918, 1935)) + list(range(1973, 1986))\n", | |
| "\n", | |
| "data = pd.DataFrame(\n", | |
| " data=np.stack([_TAHUN, _DEBIT], axis=1),\n", | |
| " columns=['tahun', 'debit']\n", | |
| ")\n", | |
| "data.tahun = pd.to_datetime(data.tahun, format='%Y')\n", | |
| "data.set_index('tahun', inplace=True)\n", | |
| "data" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 1000 | |
| }, | |
| "id": "aZAOyMcC0OIs", | |
| "outputId": "b3de6432-d0f8-49ba-9e7f-d87a78785a1e" | |
| }, | |
| "execution_count": 2, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| " debit\n", | |
| "tahun \n", | |
| "1918-01-01 244\n", | |
| "1919-01-01 217\n", | |
| "1920-01-01 285\n", | |
| "1921-01-01 261\n", | |
| "1922-01-01 295\n", | |
| "1923-01-01 252\n", | |
| "1924-01-01 275\n", | |
| "1925-01-01 204\n", | |
| "1926-01-01 208\n", | |
| "1927-01-01 194\n", | |
| "1928-01-01 256\n", | |
| "1929-01-01 207\n", | |
| "1930-01-01 354\n", | |
| "1931-01-01 445\n", | |
| "1932-01-01 350\n", | |
| "1933-01-01 336\n", | |
| "1934-01-01 328\n", | |
| "1973-01-01 269\n", | |
| "1974-01-01 323\n", | |
| "1975-01-01 364\n", | |
| "1976-01-01 247\n", | |
| "1977-01-01 290\n", | |
| "1978-01-01 302\n", | |
| "1979-01-01 301\n", | |
| "1980-01-01 284\n", | |
| "1981-01-01 276\n", | |
| "1982-01-01 261\n", | |
| "1983-01-01 303\n", | |
| "1984-01-01 335\n", | |
| "1985-01-01 320" | |
| ], | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>debit</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>tahun</th>\n", | |
| " <th></th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>1918-01-01</th>\n", | |
| " <td>244</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1919-01-01</th>\n", | |
| " <td>217</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1920-01-01</th>\n", | |
| " <td>285</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1921-01-01</th>\n", | |
| " <td>261</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1922-01-01</th>\n", | |
| " <td>295</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1923-01-01</th>\n", | |
| " <td>252</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1924-01-01</th>\n", | |
| " <td>275</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1925-01-01</th>\n", | |
| " <td>204</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1926-01-01</th>\n", | |
| " <td>208</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1927-01-01</th>\n", | |
| " <td>194</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1928-01-01</th>\n", | |
| " <td>256</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1929-01-01</th>\n", | |
| " <td>207</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1930-01-01</th>\n", | |
| " <td>354</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1931-01-01</th>\n", | |
| " <td>445</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1932-01-01</th>\n", | |
| " <td>350</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1933-01-01</th>\n", | |
| " <td>336</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1934-01-01</th>\n", | |
| " <td>328</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1973-01-01</th>\n", | |
| " <td>269</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1974-01-01</th>\n", | |
| " <td>323</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1975-01-01</th>\n", | |
| " <td>364</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1976-01-01</th>\n", | |
| " <td>247</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1977-01-01</th>\n", | |
| " <td>290</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1978-01-01</th>\n", | |
| " <td>302</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1979-01-01</th>\n", | |
| " <td>301</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1980-01-01</th>\n", | |
| " <td>284</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1981-01-01</th>\n", | |
| " <td>276</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1982-01-01</th>\n", | |
| " <td>261</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1983-01-01</th>\n", | |
| " <td>303</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1984-01-01</th>\n", | |
| " <td>335</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1985-01-01</th>\n", | |
| " <td>320</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 2 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "# TABEL\n", | |
| "\n", | |
| "Terdapat 3 tabel untuk modul `hk127` yaitu:\n", | |
| "- `t_gumbel_gb`: Tabel nilai $\\bar{y}_N$ (`yn`) dan $\\sigma_N$ (`sn`) dari Tabel 6.2.3 _Means and Standard Deviations of Reduced Extremes_ hal. 228. Sumber: _Statistics of Extremes_ oleh Gumbel, E. J. (2012)\n", | |
| "- `t_gumbel_sw`: Tabel nilai Yn (`yn`) dan Sn (`sn`) dari Tabel 3.11A Hubungan Reduksi Variat Rata-rata (Yn) dengan Jumlah Data (n) dan Tabel 3.11B Hubungan antara deviasi standar dan reduksi variat dengan jumlah data. Sumber: hidrologi: _Aplikasi Metode Statistik untuk Analisa Data_ oleh Soewarno. (1995)\n", | |
| "- `t_gumbel_st`: Tabel nilai $Y_n$ (`yn`) dan $S_n$ (`sn`) dari Tabel 12.1. $Y_n$ dan $S_n$ Gumbel. Sumber: _Rekayasa Statistika untuk Teknik Pengairan_ oleh Soetopo, W., Montarcih, L., Press, U. B., & Media, U. (2017).\n", | |
| "\n", | |
| "Dalam modul `hk127` nilai $Y_n$ dan $S_n$ akan menggunakan dari tabel `t_gumbel_gb` secara `default`. Mohon diperhatikan jika ingin menggunakan nilai $Y_n$ dan $S_n$ yang berasal dari sumber lain. \n", | |
| "\n", | |
| "Catatan: Sumber buku Gumbel dari yang tahun 1957." | |
| ], | |
| "metadata": { | |
| "id": "tydu0qwR135n" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "# tabel dari gumbel\n", | |
| "# Statistics of Extremes oleh Gumbel p.228\n", | |
| "\n", | |
| "# KODE: GB\n", | |
| "\n", | |
| "_DATA_GB = [\n", | |
| " [0.48430, 0.90430],\n", | |
| " [0.49020, 0.92880],\n", | |
| " [0.49520, 0.94970],\n", | |
| " [0.49960, 0.96760],\n", | |
| " [0.50350, 0.98330],\n", | |
| " [0.50700, 0.99720],\n", | |
| " [0.51000, 1.00950],\n", | |
| " [0.51280, 1.02057],\n", | |
| " [0.51570, 1.03160],\n", | |
| " [0.51810, 1.04110],\n", | |
| " [0.52020, 1.04930],\n", | |
| " [0.52200, 1.05660],\n", | |
| " [0.52355, 1.06283],\n", | |
| " [0.52520, 1.06960],\n", | |
| " [0.52680, 1.07540],\n", | |
| " [0.52830, 1.08110],\n", | |
| " [0.52960, 1.08640],\n", | |
| " [0.53086, 1.09145],\n", | |
| " [0.53200, 1.09610],\n", | |
| " [0.53320, 1.10040],\n", | |
| " [0.53430, 1.10470],\n", | |
| " [0.53530, 1.10860],\n", | |
| " [0.53622, 1.11238],\n", | |
| " [0.53710, 1.11590],\n", | |
| " [0.53800, 1.11930],\n", | |
| " [0.53880, 1.12260],\n", | |
| " [0.53960, 1.12550],\n", | |
| " [0.54034, 1.12847],\n", | |
| " [0.54100, 1.13130],\n", | |
| " [0.54180, 1.13390],\n", | |
| " [0.54240, 1.13630],\n", | |
| " [0.54300, 1.13880],\n", | |
| " [0.54362, 1.14132],\n", | |
| " [0.54420, 1.14360],\n", | |
| " [0.54480, 1.14580],\n", | |
| " [0.54530, 1.14800],\n", | |
| " [0.54580, 1.14990],\n", | |
| " [0.54630, 1.15185],\n", | |
| " [0.54680, 1.15380],\n", | |
| " [0.54730, 1.15570],\n", | |
| " [0.54770, 1.15740],\n", | |
| " [0.54810, 1.15900],\n", | |
| " [0.54854, 1.16066],\n", | |
| " [0.54890, 1.16230],\n", | |
| " [0.54930, 1.16380],\n", | |
| " [0.54970, 1.16530],\n", | |
| " [0.55010, 1.16670],\n", | |
| " [0.55040, 1.16810],\n", | |
| " [0.55080, 1.16960],\n", | |
| " [0.55110, 1.17080],\n", | |
| " [0.55150, 1.17210],\n", | |
| " [0.55180, 1.17340],\n", | |
| " [0.55208, 1.17467],\n", | |
| " [0.55270, 1.17700],\n", | |
| " [0.55330, 1.17930],\n", | |
| " [0.55380, 1.18140],\n", | |
| " [0.55430, 1.18340],\n", | |
| " [0.55477, 1.18536],\n", | |
| " [0.55520, 1.18730],\n", | |
| " [0.55570, 1.18900],\n", | |
| " [0.55610, 1.19060],\n", | |
| " [0.55650, 1.19230],\n", | |
| " [0.55688, 1.19382],\n", | |
| " [0.55720, 1.19530],\n", | |
| " [0.55760, 1.19670],\n", | |
| " [0.55800, 1.19800],\n", | |
| " [0.55830, 1.19940],\n", | |
| " [0.55860, 1.20073],\n", | |
| " [0.55890, 1.20200],\n", | |
| " [0.55920, 1.20320],\n", | |
| " [0.55950, 1.20440],\n", | |
| " [0.55980, 1.20550],\n", | |
| " [0.56002, 1.20649],\n", | |
| " [0.56461, 1.22534],\n", | |
| " [0.56715, 1.23598],\n", | |
| " [0.56878, 1.24292],\n", | |
| " [0.56993, 1.24786],\n", | |
| " [0.57144, 1.25450],\n", | |
| " [0.57240, 1.25880],\n", | |
| " [0.57377, 1.26506],\n", | |
| " [0.57450, 1.26851]\n", | |
| "]\n", | |
| "\n", | |
| "_INDEX_GB = (\n", | |
| " list(range(8, 61)) +\n", | |
| " list(range(62, 101, 2)) +\n", | |
| " list(range(150, 301, 50)) +\n", | |
| " [400, 500, 750, 1000]\n", | |
| ")\n", | |
| "\n", | |
| "_COL_GB = ['yn', 'sn']\n", | |
| "\n", | |
| "t_gumbel_gb = pd.DataFrame(\n", | |
| " data=_DATA_GB, index=_INDEX_GB, columns=_COL_GB\n", | |
| ")\n", | |
| "t_gumbel_gb" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 424 | |
| }, | |
| "id": "Q3uSbmX-21L3", | |
| "outputId": "a877d0bf-53cf-448b-d288-0336772209b2" | |
| }, | |
| "execution_count": 3, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| " yn sn\n", | |
| "8 0.48430 0.90430\n", | |
| "9 0.49020 0.92880\n", | |
| "10 0.49520 0.94970\n", | |
| "11 0.49960 0.96760\n", | |
| "12 0.50350 0.98330\n", | |
| "... ... ...\n", | |
| "300 0.56993 1.24786\n", | |
| "400 0.57144 1.25450\n", | |
| "500 0.57240 1.25880\n", | |
| "750 0.57377 1.26506\n", | |
| "1000 0.57450 1.26851\n", | |
| "\n", | |
| "[81 rows x 2 columns]" | |
| ], | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>yn</th>\n", | |
| " <th>sn</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>8</th>\n", | |
| " <td>0.48430</td>\n", | |
| " <td>0.90430</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>9</th>\n", | |
| " <td>0.49020</td>\n", | |
| " <td>0.92880</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>10</th>\n", | |
| " <td>0.49520</td>\n", | |
| " <td>0.94970</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>11</th>\n", | |
| " <td>0.49960</td>\n", | |
| " <td>0.96760</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>12</th>\n", | |
| " <td>0.50350</td>\n", | |
| " <td>0.98330</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>...</th>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>300</th>\n", | |
| " <td>0.56993</td>\n", | |
| " <td>1.24786</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>400</th>\n", | |
| " <td>0.57144</td>\n", | |
| " <td>1.25450</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>500</th>\n", | |
| " <td>0.57240</td>\n", | |
| " <td>1.25880</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>750</th>\n", | |
| " <td>0.57377</td>\n", | |
| " <td>1.26506</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1000</th>\n", | |
| " <td>0.57450</td>\n", | |
| " <td>1.26851</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "<p>81 rows × 2 columns</p>\n", | |
| "</div>" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 3 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "# tabel dari soewarno\n", | |
| "# Tabel 3.11A & 3.11B p.129-130\n", | |
| "\n", | |
| "# KODE: GB\n", | |
| "\n", | |
| "_DATA_SW = [\n", | |
| " [0.4592, 0.9496],\n", | |
| " [0.4996, 0.9676],\n", | |
| " [0.5053, 0.9933],\n", | |
| " [0.5070, 0.9971],\n", | |
| " [0.5100, 1.0095],\n", | |
| " [0.5128, 1.0206],\n", | |
| " [0.5157, 1.0316],\n", | |
| " [0.5181, 1.0411],\n", | |
| " [0.5202, 1.0493],\n", | |
| " [0.5220, 1.0565],\n", | |
| " [0.5236, 1.0628],\n", | |
| " [0.5252, 1.0696],\n", | |
| " [0.5268, 1.0754],\n", | |
| " [0.5283, 1.0811],\n", | |
| " [0.5296, 1.0864],\n", | |
| " [0.5309, 1.0915],\n", | |
| " [0.5320, 1.1961],\n", | |
| " [0.5332, 1.1004],\n", | |
| " [0.5343, 1.1047],\n", | |
| " [0.5353, 1.1086],\n", | |
| " [0.5362, 1.1124],\n", | |
| " [0.5371, 1.1159],\n", | |
| " [0.5380, 1.1193],\n", | |
| " [0.5388, 1.1226],\n", | |
| " [0.5396, 1.1255],\n", | |
| " [0.5402, 1.1285],\n", | |
| " [0.5410, 1.1313],\n", | |
| " [0.5418, 1.1339],\n", | |
| " [0.5424, 1.1363],\n", | |
| " [0.5430, 1.1388],\n", | |
| " [0.5436, 1.1413],\n", | |
| " [0.5442, 1.1436],\n", | |
| " [0.5448, 1.1458],\n", | |
| " [0.5453, 1.1480],\n", | |
| " [0.5458, 1.1499],\n", | |
| " [0.5463, 1.1519],\n", | |
| " [0.5468, 1.1538],\n", | |
| " [0.5473, 1.1557],\n", | |
| " [0.5477, 1.1574],\n", | |
| " [0.5481, 1.1590],\n", | |
| " [0.5485, 1.1607],\n", | |
| " [0.5489, 1.1623],\n", | |
| " [0.5493, 1.1638],\n", | |
| " [0.5497, 1.1658],\n", | |
| " [0.5501, 1.1667],\n", | |
| " [0.5504, 1.1681],\n", | |
| " [0.5508, 1.1696],\n", | |
| " [0.5511, 1.1708],\n", | |
| " [0.5518, 1.1721],\n", | |
| " [0.5518, 1.1734],\n", | |
| " [0.5521, 1.1747],\n", | |
| " [0.5524, 1.1759],\n", | |
| " [0.5527, 1.1770],\n", | |
| " [0.5530, 1.1782],\n", | |
| " [0.5533, 1.1793],\n", | |
| " [0.5535, 1.1803],\n", | |
| " [0.5538, 1.1814],\n", | |
| " [0.5540, 1.1824],\n", | |
| " [0.5543, 1.1834],\n", | |
| " [0.5545, 1.1844],\n", | |
| " [0.5548, 1.1854],\n", | |
| " [0.5550, 1.1863],\n", | |
| " [0.5552, 1.1873],\n", | |
| " [0.5555, 1.1881],\n", | |
| " [0.5557, 1.1890],\n", | |
| " [0.5559, 1.1898],\n", | |
| " [0.5561, 1.1906],\n", | |
| " [0.5563, 1.1915],\n", | |
| " [0.5565, 1.1923],\n", | |
| " [0.5567, 1.1930],\n", | |
| " [0.5569, 1.1938],\n", | |
| " [0.5570, 1.1945],\n", | |
| " [0.5572, 1.1953],\n", | |
| " [0.5574, 1.1959],\n", | |
| " [0.5576, 1.1967],\n", | |
| " [0.5578, 1.1973],\n", | |
| " [0.5580, 1.1980],\n", | |
| " [0.5581, 1.1987],\n", | |
| " [0.5583, 1.1994],\n", | |
| " [0.5585, 1.2001],\n", | |
| " [0.5586, 1.2007],\n", | |
| " [0.5587, 1.2013],\n", | |
| " [0.5589, 1.2020],\n", | |
| " [0.5591, 1.2026],\n", | |
| " [0.5592, 1.2032],\n", | |
| " [0.5593, 1.2038],\n", | |
| " [0.5595, 1.2044],\n", | |
| " [0.5596, 1.2049],\n", | |
| " [0.5598, 1.2055],\n", | |
| " [0.5599, 1.2060],\n", | |
| " [0.5600, 1.2065],\n", | |
| "]\n", | |
| "\n", | |
| "_INDEX_SW = list(range(10, 101))\n", | |
| "\n", | |
| "_COL_SW = ['yn', 'sn']\n", | |
| "\n", | |
| "t_gumbel_sw = pd.DataFrame(\n", | |
| " data=_DATA_SW, index=_INDEX_SW, columns=_COL_SW\n", | |
| ")\n", | |
| "t_gumbel_sw" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 424 | |
| }, | |
| "id": "dMgC8ZMU4aFH", | |
| "outputId": "afa836c5-a9a0-4719-e1a0-1f81a81407d4" | |
| }, | |
| "execution_count": 4, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| " yn sn\n", | |
| "10 0.4592 0.9496\n", | |
| "11 0.4996 0.9676\n", | |
| "12 0.5053 0.9933\n", | |
| "13 0.5070 0.9971\n", | |
| "14 0.5100 1.0095\n", | |
| ".. ... ...\n", | |
| "96 0.5595 1.2044\n", | |
| "97 0.5596 1.2049\n", | |
| "98 0.5598 1.2055\n", | |
| "99 0.5599 1.2060\n", | |
| "100 0.5600 1.2065\n", | |
| "\n", | |
| "[91 rows x 2 columns]" | |
| ], | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>yn</th>\n", | |
| " <th>sn</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>10</th>\n", | |
| " <td>0.4592</td>\n", | |
| " <td>0.9496</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>11</th>\n", | |
| " <td>0.4996</td>\n", | |
| " <td>0.9676</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>12</th>\n", | |
| " <td>0.5053</td>\n", | |
| " <td>0.9933</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>13</th>\n", | |
| " <td>0.5070</td>\n", | |
| " <td>0.9971</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>14</th>\n", | |
| " <td>0.5100</td>\n", | |
| " <td>1.0095</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>...</th>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>96</th>\n", | |
| " <td>0.5595</td>\n", | |
| " <td>1.2044</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>97</th>\n", | |
| " <td>0.5596</td>\n", | |
| " <td>1.2049</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>98</th>\n", | |
| " <td>0.5598</td>\n", | |
| " <td>1.2055</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>99</th>\n", | |
| " <td>0.5599</td>\n", | |
| " <td>1.2060</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>100</th>\n", | |
| " <td>0.5600</td>\n", | |
| " <td>1.2065</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "<p>91 rows × 2 columns</p>\n", | |
| "</div>" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 4 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "# Tabel dari Soetopo hal. 98\n", | |
| "# Tabel 12.1 Yn dan Sn Gumbel \n", | |
| "\n", | |
| "# KODE: ST\n", | |
| "\n", | |
| "_DATA_ST = [\n", | |
| " [0.4843, 0.9043],\n", | |
| " [0.4902, 0.9288],\n", | |
| " [0.4952, 0.9497],\n", | |
| " [0.4996, 0.9676],\n", | |
| " [0.5035, 0.9833],\n", | |
| " [0.5070, 0.9972],\n", | |
| " [0.5100, 1.0095],\n", | |
| " [0.5128, 1.0205],\n", | |
| " [0.5157, 1.0316],\n", | |
| " [0.5181, 1.0411],\n", | |
| " [0.5202, 1.0493],\n", | |
| " [0.5220, 1.0566],\n", | |
| " [0.5235, 1.0628],\n", | |
| " [0.5252, 1.0696],\n", | |
| " [0.5268, 1.0754],\n", | |
| " [0.5283, 1.0811],\n", | |
| " [0.5296, 1.0864],\n", | |
| " [0.5309, 1.0915],\n", | |
| " [0.5320, 1.0961],\n", | |
| " [0.5332, 1.1004],\n", | |
| " [0.5343, 1.1047],\n", | |
| " [0.5353, 1.1086],\n", | |
| " [0.5362, 1.1124],\n", | |
| " [0.5371, 1.1159],\n", | |
| " [0.5380, 1.1193],\n", | |
| " [0.5388, 1.1226],\n", | |
| " [0.5396, 1.1255],\n", | |
| " [0.5402, 1.1285],\n", | |
| " [0.5410, 1.1313],\n", | |
| " [0.5418, 1.1339],\n", | |
| " [0.5424, 1.1363],\n", | |
| " [0.5430, 1.1388],\n", | |
| " [0.5436, 1.1413],\n", | |
| " [0.5442, 1.1436],\n", | |
| " [0.5448, 1.1458],\n", | |
| " [0.5453, 1.1480],\n", | |
| " [0.5458, 1.1499],\n", | |
| " [0.5463, 1.1519],\n", | |
| " [0.5468, 1.1538],\n", | |
| " [0.5473, 1.1557],\n", | |
| " [0.5477, 1.1574],\n", | |
| " [0.5481, 1.1590],\n", | |
| " [0.5485, 1.1607],\n", | |
| " [0.5489, 1.1623],\n", | |
| " [0.5493, 1.1638],\n", | |
| " [0.5497, 1.1658],\n", | |
| " [0.5501, 1.1667],\n", | |
| " [0.5504, 1.1681],\n", | |
| " [0.5508, 1.1696],\n", | |
| " [0.5511, 1.1708],\n", | |
| " [0.5515, 1.1721],\n", | |
| " [0.5518, 1.1734],\n", | |
| " [0.5521, 1.1747],\n", | |
| " [0.5524, 1.1759],\n", | |
| " [0.5527, 1.1770],\n", | |
| " [0.5530, 1.1782],\n", | |
| " [0.5533, 1.1793],\n", | |
| " [0.5535, 1.1803],\n", | |
| " [0.5538, 1.1814],\n", | |
| " [0.5540, 1.1824],\n", | |
| " [0.5543, 1.1834],\n", | |
| " [0.5545, 1.1844],\n", | |
| " [0.5548, 1.1854],\n", | |
| " [0.5550, 1.1863],\n", | |
| " [0.5552, 1.1873],\n", | |
| " [0.5555, 1.1881],\n", | |
| " [0.5557, 1.1890],\n", | |
| " [0.5559, 1.1898],\n", | |
| " [0.5561, 1.1906],\n", | |
| " [0.5563, 1.1915],\n", | |
| " [0.5565, 1.1923],\n", | |
| " [0.5567, 1.1930],\n", | |
| " [0.5569, 1.1938],\n", | |
| " [0.5570, 1.1945],\n", | |
| " [0.5572, 1.1953],\n", | |
| " [0.5574, 1.1959],\n", | |
| " [0.5576, 1.1967],\n", | |
| " [0.5578, 1.1973],\n", | |
| " [0.5580, 1.1980],\n", | |
| " [0.5581, 1.1987],\n", | |
| " [0.5583, 1.1994],\n", | |
| " [0.5585, 1.2001],\n", | |
| " [0.5586, 1.2007],\n", | |
| " [0.5587, 1.2013],\n", | |
| " [0.5589, 1.2020],\n", | |
| " [0.5591, 1.2026],\n", | |
| " [0.5592, 1.2032],\n", | |
| " [0.5593, 1.2038],\n", | |
| " [0.5595, 1.2044],\n", | |
| " [0.5596, 1.2049],\n", | |
| " [0.5598, 1.2055],\n", | |
| " [0.5599, 1.2060],\n", | |
| " [0.5600, 1.2065],\n", | |
| "]\n", | |
| "\n", | |
| "_INDEX_ST = list(range(8, 101))\n", | |
| "\n", | |
| "_COL_ST = ['yn', 'sn']\n", | |
| "\n", | |
| "t_gumbel_st = pd.DataFrame(\n", | |
| " data=_DATA_ST, index=_INDEX_ST, columns=_COL_ST\n", | |
| ")\n", | |
| "t_gumbel_st" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 424 | |
| }, | |
| "id": "gcHHA1gb_MvM", | |
| "outputId": "1574a9f3-9a0c-45c0-efed-21dbfc6e5b81" | |
| }, | |
| "execution_count": 5, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| " yn sn\n", | |
| "8 0.4843 0.9043\n", | |
| "9 0.4902 0.9288\n", | |
| "10 0.4952 0.9497\n", | |
| "11 0.4996 0.9676\n", | |
| "12 0.5035 0.9833\n", | |
| ".. ... ...\n", | |
| "96 0.5595 1.2044\n", | |
| "97 0.5596 1.2049\n", | |
| "98 0.5598 1.2055\n", | |
| "99 0.5599 1.2060\n", | |
| "100 0.5600 1.2065\n", | |
| "\n", | |
| "[93 rows x 2 columns]" | |
| ], | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>yn</th>\n", | |
| " <th>sn</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>8</th>\n", | |
| " <td>0.4843</td>\n", | |
| " <td>0.9043</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>9</th>\n", | |
| " <td>0.4902</td>\n", | |
| " <td>0.9288</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>10</th>\n", | |
| " <td>0.4952</td>\n", | |
| " <td>0.9497</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>11</th>\n", | |
| " <td>0.4996</td>\n", | |
| " <td>0.9676</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>12</th>\n", | |
| " <td>0.5035</td>\n", | |
| " <td>0.9833</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>...</th>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>96</th>\n", | |
| " <td>0.5595</td>\n", | |
| " <td>1.2044</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>97</th>\n", | |
| " <td>0.5596</td>\n", | |
| " <td>1.2049</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>98</th>\n", | |
| " <td>0.5598</td>\n", | |
| " <td>1.2055</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>99</th>\n", | |
| " <td>0.5599</td>\n", | |
| " <td>1.2060</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>100</th>\n", | |
| " <td>0.5600</td>\n", | |
| " <td>1.2065</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "<p>93 rows × 2 columns</p>\n", | |
| "</div>" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 5 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "# KODE" | |
| ], | |
| "metadata": { | |
| "id": "ULqzeasu2P2f" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "def _find_in_table(val, table, y_col=None, x_col=None):\n", | |
| " x = table.index if x_col is None else table[x_col]\n", | |
| " y = table.iloc[:, 0] if y_col is None else table[y_col]\n", | |
| " return np.interp(val, x, y)\n", | |
| "\n", | |
| "def _find_Yn_Sn(n, table):\n", | |
| " yn = _find_in_table(n, table, y_col='yn')\n", | |
| " sn = _find_in_table(n, table, y_col='sn')\n", | |
| " return yn, sn" | |
| ], | |
| "metadata": { | |
| "id": "XEqz2ZHWf4gf" | |
| }, | |
| "execution_count": 6, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "def find_coef(n, source='gumbel'):\n", | |
| " if source.lower() == 'gumbel':\n", | |
| " return _find_Yn_Sn(n, t_gumbel_gb)\n", | |
| " if source.lower() == 'soewarno':\n", | |
| " return _find_Yn_Sn(n, t_gumbel_sw)\n", | |
| " if source.lower() == 'soetopo':\n", | |
| " return _find_Yn_Sn(n, t_gumbel_st)\n", | |
| "\n", | |
| "def calc_K(n, return_period, source='gumbel', show_stat=False):\n", | |
| " return_period = np.array(return_period)\n", | |
| "\n", | |
| " if source.lower() == 'scipy':\n", | |
| " # todo: perhitungan probabilitasnya belum dapat dipastikan formulanya\n", | |
| " prob = 1 - 1/return_period\n", | |
| " # prob = 1 - np.log(return_period/(return_period-1))\n", | |
| " return stats.gumbel_r.ppf(prob)\n", | |
| " elif source.lower() == 'powell':\n", | |
| " return -np.sqrt(6)/np.pi *(np.euler_gamma+np.log(np.log(return_period/(return_period-1))))\n", | |
| " else:\n", | |
| " # dibuku Soewarno dinyatakan T>=20 menggunakan\n", | |
| " # ln(T), tapi dicontohnya tidak mengikuti formula tersebut\n", | |
| " # jadi yang digunakan rumus umumnya saja.\n", | |
| " # if source.lower() == 'soewarno':\n", | |
| " # yt = []\n", | |
| " # for t in return_period:\n", | |
| " # if t <= 20:\n", | |
| " # yt += [-np.log(-np.log((t - 1)/t))]\n", | |
| " # else:\n", | |
| " # yt += [np.log(t)]\n", | |
| " # yt = np.array(yt)\n", | |
| " # else:\n", | |
| " # yt = -np.log(-np.log((return_period - 1)/return_period))\n", | |
| "\n", | |
| " yn, sn = find_coef(n, source=source)\n", | |
| " yt = -np.log(-np.log((return_period - 1)/return_period))\n", | |
| " K = (yt - yn) / sn\n", | |
| "\n", | |
| " if show_stat:\n", | |
| " print(f'y_n = {yn}')\n", | |
| " print(f's_n = {sn}')\n", | |
| " print(f'y_t = {yt}')\n", | |
| " return K\n", | |
| "\n", | |
| "def calc_x_gumbel(x, return_period=[5], source='gumbel', show_stat=False):\n", | |
| "\n", | |
| " x_mean = np.mean(x)\n", | |
| " x_std = np.std(x, ddof=1)\n", | |
| " n = len(x)\n", | |
| "\n", | |
| " k = calc_K(n, return_period, source=source, show_stat=show_stat)\n", | |
| "\n", | |
| " if show_stat:\n", | |
| " print(f'x_mean = {x_mean:.5f}')\n", | |
| " print(f'x_std = {x_std:.5f}')\n", | |
| " print(f'k = {k}')\n", | |
| " \n", | |
| " val_x = x_mean + k * x_std\n", | |
| " return val_x\n", | |
| "\n", | |
| "def freq_gumbel(\n", | |
| " df, col=None,\n", | |
| " return_period=[2, 5, 10, 20, 25, 50, 100], source='gumbel', show_stat=False,\n", | |
| " col_name='Gumbel', index_name='Kala Ulang'):\n", | |
| "\n", | |
| " col = df.columns[0] if col is None else col\n", | |
| "\n", | |
| " x = df[col].copy()\n", | |
| "\n", | |
| " arr = calc_x_gumbel(\n", | |
| " x, return_period=return_period, show_stat=show_stat,\n", | |
| " source=source\n", | |
| " )\n", | |
| "\n", | |
| " result = pd.DataFrame(\n", | |
| " data=arr, index=return_period, columns=[col_name]\n", | |
| " )\n", | |
| "\n", | |
| " result.index.name = index_name\n", | |
| " return result" | |
| ], | |
| "metadata": { | |
| "id": "hVrQdk5ZicdA" | |
| }, | |
| "execution_count": 7, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "def _calc_T(P):\n", | |
| " return 1 / (1-np.exp(-np.exp(-P)))\n", | |
| "\n", | |
| "def _calc_prob_from_table(k, n, source='gumbel'):\n", | |
| " yn, sn = find_coef(n, source=source)\n", | |
| " P = k * sn + yn\n", | |
| " T = _calc_T(P)\n", | |
| " return np.around(1-1/T, 3)\n", | |
| "\n", | |
| "def calc_prob(k, n, source='gumbel'):\n", | |
| " if source.lower() == 'gumbel':\n", | |
| " return _calc_prob_from_table(k, n, source=source)\n", | |
| " if source.lower() == 'soewarno':\n", | |
| " return _calc_prob_from_table(k, n, source=source)\n", | |
| " if source.lower() == 'soetopo':\n", | |
| " return _calc_prob_from_table(k, n, source=source)\n", | |
| " if source.lower() == 'scipy':\n", | |
| " return stats.gumbel_r.cdf(k)\n", | |
| " if source.lower() == 'powell':\n", | |
| " # persamaan ini ditemukan menggunakan wolfram alpha\n", | |
| " # x = e^(e^(-(π K)/sqrt(6) - p))/(e^(e^(-(π K)/sqrt(6) - p)) - 1)\n", | |
| " _top = np.exp(np.exp(-(np.pi*k)/np.sqrt(6)-np.euler_gamma))\n", | |
| " _bot = _top - 1\n", | |
| " T = _top / _bot\n", | |
| " return 1-1/T" | |
| ], | |
| "metadata": { | |
| "id": "kf11-u4Jbx_G" | |
| }, | |
| "execution_count": 8, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "# FUNGSI" | |
| ], | |
| "metadata": { | |
| "id": "K-SN5xLw0AP_" | |
| } | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "## Fungsi `find_coef(n, ...)`\n", | |
| "\n", | |
| "Function: `find_coef(n, source='gumbel')`\n", | |
| "\n", | |
| "Fungsi `find_coef(...)` digunakan untuk mencari nilai $Y_n$ dan $S_n$ dari berbagai sumber berdasarkan nilai $n$ yaitu jumlah banyaknya data. \n", | |
| "\n", | |
| "- Argumen Posisi:\n", | |
| " - `n`: jumlah banyaknya data.\n", | |
| "- Argumen Opsional:\n", | |
| " - `source`: sumber nilai $Y_n$ dan $S_n$, `'gumbel'` (default). Sumber yang dapat digunakan antara lain: Soewarno (`'soewarno'`), Soetopo (`'soetopo'`).\n", | |
| "\n", | |
| "Perlu dicatat bahwa batas jumlah data $N$ untuk masing-masing sumber berbeda-beda. \n", | |
| "- Untuk `'gumbel'` batasan dimulai dari $[8, ∞]$ akan tetapi pada tabel hanya sampai $1000$.\n", | |
| "- Untuk `'soewarno'` batasan dimulai dari $[10, 100]$.\n", | |
| "- Untuk `'soetopo'` batasan dimulai dari $[10, 100]$. " | |
| ], | |
| "metadata": { | |
| "id": "KQoovCuO0_sH" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "find_coef(10)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "0Bs_qxqb2v1R", | |
| "outputId": "d89e43d3-6b7d-4d4c-9912-7d921811cd8f" | |
| }, | |
| "execution_count": 9, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| "(0.4952, 0.9497)" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 9 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "find_coef(30, source='soetopo') # menggunakan tabel dari soetopo" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "vegebmxq2yOr", | |
| "outputId": "f8d5c2ad-1913-4080-89c9-bcf69378aaa8" | |
| }, | |
| "execution_count": 10, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| "(0.5362, 1.1124)" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 10 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "# perbandingan antara masing-masing sumber\n", | |
| "\n", | |
| "_n = 25\n", | |
| "source_test = ['gumbel', 'soewarno', 'soetopo']\n", | |
| "\n", | |
| "for _source in source_test:\n", | |
| " print(f'Yn, Sn {_source:10}= {find_coef(_n, source=_source)}')" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "UtBTkAZg3BLc", | |
| "outputId": "10407bdf-ed7c-4fb9-a552-9e7e5414d8bc" | |
| }, | |
| "execution_count": 11, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "Yn, Sn gumbel = (0.53086, 1.09145)\n", | |
| "Yn, Sn soewarno = (0.5309, 1.0915)\n", | |
| "Yn, Sn soetopo = (0.5309, 1.0915)\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "## Fungsi `calc_K(n, return_period, ...)`:\n", | |
| "\n", | |
| "Function: `calc_K(n, return_period, source='gumbel', show_stat=False)`\n", | |
| "\n", | |
| "Fungsi `calc_K(...)` digunakan untuk menghitung nilai frequency factor $K$ yang digunakan untuk menghitung nilai $X$ pada kala ulang tertentu. \n", | |
| "\n", | |
| "- Argumen Posisi:\n", | |
| " - `n`: jumlah banyaknya data.\n", | |
| " - `return_period`: kala ulang. Bisa dalam skalar ataupun _array_like_.\n", | |
| "- Argumen Opsional:\n", | |
| " - `source`: sumber nilai $Y_n$ dan $S_n$ (untuk `'gumbel'`, `'soewarno'`, dan `'soetopo'`), `'gumbel'` (default). Sumber yang dapat digunakan antara lain: Soewarno (`'soewarno'`), Soetopo (`'soetopo'`), fungsi `stats.gumbel_r.ppf` dari Scipy (`'scipy'`), dan metode Powell (`'powell'`).\n", | |
| " - `show_stat`: menampilkan parameter statistik. `False` (default).\n", | |
| "\n", | |
| "Catatan:\n", | |
| "Untuk metode Powell (`'powell'`) menggunakan persamaan:\n", | |
| "$$K = - \\frac{\\sqrt{6}}{\\pi} \\left( \\gamma + \\ln{\\ln\\left({\\frac{T}{T-1}}\\right)}\\right)$$\n", | |
| "dengan $\\gamma = 0.5772$ (`np.euler_gamma`) atau merupakan bilangan [**Euler–Mascheroni constant**](https://en.wikipedia.org/wiki/Euler%27s_constant). " | |
| ], | |
| "metadata": { | |
| "id": "SXHRrtpc35Dm" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "calc_K(10, 10)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "xYeTcR7v77S5", | |
| "outputId": "a0b8344c-4a85-45af-b33f-f2546048ca2b" | |
| }, | |
| "execution_count": 12, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| "1.8481281744892548" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 12 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "calc_K(10, [10, 20, 50], source='soetopo')" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "in7gOJJm8fSL", | |
| "outputId": "0496f1f8-e140-4b29-a78d-a1492ba88ceb" | |
| }, | |
| "execution_count": 13, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| "array([1.84812817, 2.60608113, 3.58717348])" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 13 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "calc_K(10, [10, 20, 50], source='soewarno', show_stat=True)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "ViEpU_wE8nLS", | |
| "outputId": "fd1c4aeb-6798-49b1-e7d7-fcffa1f290df" | |
| }, | |
| "execution_count": 14, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "y_n = 0.4592\n", | |
| "s_n = 0.9496\n", | |
| "y_t = [2.25036733 2.97019525 3.90193866]\n" | |
| ] | |
| }, | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| "array([1.8862335 , 2.64426627, 3.62546194])" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 14 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "## Fungsi `calc_x_gumbel(x, ...)`\n", | |
| "\n", | |
| "Function: `calc_x_gumbel(x, return_period=[5], source='gumbel', show_stat=False)`\n", | |
| "\n", | |
| "Fungsi `calc_x_gumbel(...)` digunakan untuk mencari besar $X$ berdasarkan kala ulang (_return period_), yang hasilnya dalam bentuk `numpy.array`. \n", | |
| "\n", | |
| "- Argumen Posisi:\n", | |
| " - `x`: _array_.\n", | |
| "- Argumen Opsional:\n", | |
| " - `return_period`: Kala Ulang (Tahun). `[5]` (default). \n", | |
| " - `source`: sumber nilai $K$, `'gumbel'` (default). Sumber yang dapat digunakan antara lain: Soewarno (`'soewarno'`), Soetopo (`'soetopo'`), fungsi `stats.gumbel_r.ppf` dari Scipy (`'scipy'`), dan metode Powell (`'powell'`).\n", | |
| " - `show_stat`: menampilkan parameter statistik. `False` (default)." | |
| ], | |
| "metadata": { | |
| "id": "vRZNOKdT9icS" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "calc_x_gumbel(data.debit)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "IdlaPmzS-Bxz", | |
| "outputId": "7a920728-dbc8-4947-873f-bf834f3c2da4" | |
| }, | |
| "execution_count": 15, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| "array([334.33496634])" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 15 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "calc_x_gumbel(data.debit, show_stat=True)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "aGebieZ--EO2", | |
| "outputId": "72fc91b6-6383-4c54-9c93-fd2930ce1be8" | |
| }, | |
| "execution_count": 16, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "y_n = 0.53622\n", | |
| "s_n = 1.11238\n", | |
| "y_t = [1.49993999]\n", | |
| "x_mean = 286.20000\n", | |
| "x_std = 55.56009\n", | |
| "k = [0.86635861]\n" | |
| ] | |
| }, | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| "array([334.33496634])" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 16 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "calc_x_gumbel(data.debit, return_period=[5, 10, 15, 20, 21], show_stat=True)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "RkQBT7jawK_J", | |
| "outputId": "12940ece-f907-44a9-ccf1-62782e3f53e7" | |
| }, | |
| "execution_count": 17, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "y_n = 0.53622\n", | |
| "s_n = 1.11238\n", | |
| "y_t = [1.49993999 2.25036733 2.67375209 2.97019525 3.02022654]\n", | |
| "x_mean = 286.20000\n", | |
| "x_std = 55.56009\n", | |
| "k = [0.86635861 1.5409728 1.92158443 2.18807894 2.23305574]\n" | |
| ] | |
| }, | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| "array([334.33496634, 371.81659511, 392.96341332, 407.7698733 ,\n", | |
| " 410.2687885 ])" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 17 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "## Fungsi `freq_gumbel(df, ...)`\n", | |
| "\n", | |
| "Function: `freq_gumbel(df, col=None, return_period=[2, 5, 10, 20, 25, 50, 100], source='gumbel', show_stat=False, col_name='Gumbel')`\n", | |
| "\n", | |
| "Fungsi `freq_gumbel(...)` merupakan fungsi kembangan lebih lanjut dari `calc_x_gumbel(...)` yang menerima input `pandas.DataFrame` dan memiliki luaran berupa `pandas.DataFrame`. \n", | |
| "\n", | |
| "- Argumen Posisi:\n", | |
| " - `df`: `pandas.DataFrame`.\n", | |
| "- Argumen Opsional:\n", | |
| " - `col`: nama kolom, `None` (default). Jika tidak diisi menggunakan kolom pertama dalam `df` sebagai data masukan.\n", | |
| " - `return_period`: Kala Ulang (Tahun), `[2, 5, 10, 20, 25, 50, 100]` (default).\n", | |
| " - `source`: sumber nilai $K$, `'gumbel'` (default). Sumber yang dapat digunakan antara lain: Soewarno (`'soewarno'`), Soetopo (`'soetopo'`), fungsi `stats.gumbel_r.ppf` dari Scipy (`'scipy'`), dan metode Powell (`'powell'`).\n", | |
| " - `show_stat`: menampilkan parameter statistik. `False` (default).\n", | |
| " - `col_name`: Nama kolom luaran, `Gumbel` (default). " | |
| ], | |
| "metadata": { | |
| "id": "0mwOcZiB8xmm" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "freq_gumbel(data)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 300 | |
| }, | |
| "id": "PKckL9dA-U12", | |
| "outputId": "a5008eb2-129a-4272-f1a0-b10a4a54491e" | |
| }, | |
| "execution_count": 18, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| " Gumbel\n", | |
| "Kala Ulang \n", | |
| "2 277.723633\n", | |
| "5 334.334966\n", | |
| "10 371.816595\n", | |
| "20 407.769873\n", | |
| "25 419.174732\n", | |
| "50 454.307704\n", | |
| "100 489.181259" | |
| ], | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>Gumbel</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>Kala Ulang</th>\n", | |
| " <th></th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>277.723633</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>5</th>\n", | |
| " <td>334.334966</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>10</th>\n", | |
| " <td>371.816595</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>20</th>\n", | |
| " <td>407.769873</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>25</th>\n", | |
| " <td>419.174732</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>50</th>\n", | |
| " <td>454.307704</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>100</th>\n", | |
| " <td>489.181259</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 18 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "freq_gumbel(data, source='soewarno', col_name='Gumbel (Soewarno)')" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 300 | |
| }, | |
| "id": "pFpkfGj2zW7y", | |
| "outputId": "da99006d-3cc4-4683-afd1-e865db6f0bf5" | |
| }, | |
| "execution_count": 19, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| " Gumbel (Soewarno)\n", | |
| "Kala Ulang \n", | |
| "2 277.724784\n", | |
| "5 334.335100\n", | |
| "10 371.816055\n", | |
| "20 407.768686\n", | |
| "25 419.173341\n", | |
| "50 454.305681\n", | |
| "100 489.178609" | |
| ], | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>Gumbel (Soewarno)</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>Kala Ulang</th>\n", | |
| " <th></th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>277.724784</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>5</th>\n", | |
| " <td>334.335100</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>10</th>\n", | |
| " <td>371.816055</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>20</th>\n", | |
| " <td>407.768686</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>25</th>\n", | |
| " <td>419.173341</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>50</th>\n", | |
| " <td>454.305681</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>100</th>\n", | |
| " <td>489.178609</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 19 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "freq_gumbel(data, 'debit', source='soetopo', col_name=f'LP3 (soetopo)', show_stat=True)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 439 | |
| }, | |
| "id": "Mn4MywymyWio", | |
| "outputId": "52c1e5e2-0293-4a6a-f112-9d989f75ce6f" | |
| }, | |
| "execution_count": 20, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "y_n = 0.5362\n", | |
| "s_n = 1.1124\n", | |
| "y_t = [0.36651292 1.49993999 2.25036733 2.97019525 3.19853426 3.90193866\n", | |
| " 4.60014923]\n", | |
| "x_mean = 286.20000\n", | |
| "x_std = 55.56009\n", | |
| "k = [-0.15254142 0.86636101 1.54096308 2.18805758 2.39332458 3.02565503\n", | |
| " 3.65331646]\n" | |
| ] | |
| }, | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| " LP3 (soetopo)\n", | |
| "Kala Ulang \n", | |
| "2 277.724784\n", | |
| "5 334.335100\n", | |
| "10 371.816055\n", | |
| "20 407.768686\n", | |
| "25 419.173341\n", | |
| "50 454.305681\n", | |
| "100 489.178609" | |
| ], | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>LP3 (soetopo)</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>Kala Ulang</th>\n", | |
| " <th></th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>277.724784</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>5</th>\n", | |
| " <td>334.335100</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>10</th>\n", | |
| " <td>371.816055</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>20</th>\n", | |
| " <td>407.768686</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>25</th>\n", | |
| " <td>419.173341</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>50</th>\n", | |
| " <td>454.305681</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>100</th>\n", | |
| " <td>489.178609</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 20 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "_res = []\n", | |
| "\n", | |
| "for _s in ['gumbel', 'soewarno', 'soetopo', 'powell', 'scipy', ]:\n", | |
| " _res += [freq_gumbel(data, 'debit', source=_s, col_name=f'Gumbel ({_s})')]\n", | |
| "\n", | |
| "pd.concat(_res, axis=1)" | |
| ], | |
| "metadata": { | |
| "id": "2wiAa9sp2SBt", | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 300 | |
| }, | |
| "outputId": "ed551288-48db-46c7-906c-81239c59572e" | |
| }, | |
| "execution_count": 21, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| " Gumbel (gumbel) Gumbel (soewarno) Gumbel (soetopo) \\\n", | |
| "Kala Ulang \n", | |
| "2 277.723633 277.724784 277.724784 \n", | |
| "5 334.334966 334.335100 334.335100 \n", | |
| "10 371.816595 371.816055 371.816055 \n", | |
| "20 407.769873 407.768686 407.768686 \n", | |
| "25 419.174732 419.173341 419.173341 \n", | |
| "50 454.307704 454.305681 454.305681 \n", | |
| "100 489.181259 489.178609 489.178609 \n", | |
| "\n", | |
| " Gumbel (powell) Gumbel (scipy) \n", | |
| "Kala Ulang \n", | |
| "2 277.072351 306.563493 \n", | |
| "5 326.172444 369.536808 \n", | |
| "10 358.680977 411.230622 \n", | |
| "20 389.863943 451.224330 \n", | |
| "25 399.755596 463.910867 \n", | |
| "50 430.227094 502.992082 \n", | |
| "100 460.473595 541.784727 " | |
| ], | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>Gumbel (gumbel)</th>\n", | |
| " <th>Gumbel (soewarno)</th>\n", | |
| " <th>Gumbel (soetopo)</th>\n", | |
| " <th>Gumbel (powell)</th>\n", | |
| " <th>Gumbel (scipy)</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>Kala Ulang</th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>277.723633</td>\n", | |
| " <td>277.724784</td>\n", | |
| " <td>277.724784</td>\n", | |
| " <td>277.072351</td>\n", | |
| " <td>306.563493</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>5</th>\n", | |
| " <td>334.334966</td>\n", | |
| " <td>334.335100</td>\n", | |
| " <td>334.335100</td>\n", | |
| " <td>326.172444</td>\n", | |
| " <td>369.536808</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>10</th>\n", | |
| " <td>371.816595</td>\n", | |
| " <td>371.816055</td>\n", | |
| " <td>371.816055</td>\n", | |
| " <td>358.680977</td>\n", | |
| " <td>411.230622</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>20</th>\n", | |
| " <td>407.769873</td>\n", | |
| " <td>407.768686</td>\n", | |
| " <td>407.768686</td>\n", | |
| " <td>389.863943</td>\n", | |
| " <td>451.224330</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>25</th>\n", | |
| " <td>419.174732</td>\n", | |
| " <td>419.173341</td>\n", | |
| " <td>419.173341</td>\n", | |
| " <td>399.755596</td>\n", | |
| " <td>463.910867</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>50</th>\n", | |
| " <td>454.307704</td>\n", | |
| " <td>454.305681</td>\n", | |
| " <td>454.305681</td>\n", | |
| " <td>430.227094</td>\n", | |
| " <td>502.992082</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>100</th>\n", | |
| " <td>489.181259</td>\n", | |
| " <td>489.178609</td>\n", | |
| " <td>489.178609</td>\n", | |
| " <td>460.473595</td>\n", | |
| " <td>541.784727</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 21 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "## Fungsi `calc_prob(k, n, ...)`\n", | |
| "\n", | |
| "Function: `calc_prob(k, n, source='gumbel')`\n", | |
| "\n", | |
| "Fungsi `calc_prob(...)` digunakan untuk menghitung nilai probabilitas/peluang berdasarkan nilai $K$ (_frequency factor_).\n", | |
| "\n", | |
| "- Argumen Posisi:\n", | |
| " - `k`: nilai $K$ (_frequency factor_). Nilai $K$ diperoleh menggunakan persamaan $K = \\frac{x - \\bar{x}}{s}$\n", | |
| " - `n`: jumlah banyaknya data.\n", | |
| "- Argumen Opsional:\n", | |
| " - `source`: sumber nilai $Y_n$ dan $S_n$ (untuk `'gumbel'`, `'soewarno'`, dan `'soetopo'`), `'gumbel'` (default). Sumber yang dapat digunakan antara lain: Soewarno (`'soewarno'`), Soetopo (`'soetopo'`), fungsi `stats.gumbel_r.ppf` dari Scipy (`'scipy'`), dan metode Powell (`'powell'`).\n", | |
| "\n", | |
| "Catatan:\n", | |
| "\n", | |
| "- Metode tabel (`'gumbel', 'soewarno', 'soetopo'`)\n", | |
| "\n", | |
| " Nilai probabilitas/peluang diperoleh menggunakan formula $P=1-\\frac{1}{T}$\n", | |
| "\n", | |
| "- Metode Powell (`'powell'`)\n", | |
| "\n", | |
| " Nilai kala ulang $T$ (Tahun) untuk metode Powell menggunakan persamaan berikut:\n", | |
| " $$T=\\frac{e^{e^{-\\left(\\pi k\\right)/\\sqrt{6}-\\gamma}}}{e^{e^{-\\left(\\pi k\\right)/\\sqrt{6}-\\gamma}}-1}$$\n", | |
| " dengan $\\gamma = 0.5772$ (`np.euler_gamma`) atau merupakan bilangan [**Euler–Mascheroni constant**](https://en.wikipedia.org/wiki/Euler%27s_constant). \n", | |
| "\n", | |
| " Nilai probabilitas/peluang diperoleh menggunakan formula $P=1-\\frac{1}{T}$\n", | |
| "\n", | |
| "- Metode scipy (`'scipy'`)\n", | |
| "\n", | |
| " Nilai probabilitas diperoleh menggunakan fungsi `stats.gumbel_r.cdf(...)`." | |
| ], | |
| "metadata": { | |
| "id": "3ZLvMbrzb1Sw" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "_k = calc_K(data.size, [1.001, 1.005, 1.01, 1.05, 1.11, 1.25, 1.33, 1.43, 1.67, 2, 2.5, 3.33, 4, 5, 10, 20, 50, 100, 200, 500, 1000])\n", | |
| "_k" | |
| ], | |
| "metadata": { | |
| "id": "bPBdmAN5b2X4", | |
| "outputId": "73b284e9-138f-4b55-b764-ffeafb419668", | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| } | |
| }, | |
| "execution_count": 22, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| "array([-2.21957372, -1.98183192, -1.85688162, -1.48291416, -1.23534677,\n", | |
| " -0.90985544, -0.78056388, -0.64718086, -0.40052 , -0.15256215,\n", | |
| " 0.12181718, 0.44365066, 0.63798281, 0.86635861, 1.5409728 ,\n", | |
| " 2.18807894, 3.02569145, 3.65336416, 4.2787466 , 5.10381998,\n", | |
| " 5.72739088])" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 22 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "calc_prob(_k, data.size)" | |
| ], | |
| "metadata": { | |
| "id": "C6mSu3Bxb3zD", | |
| "outputId": "ad92ab9a-b505-4743-a76e-a97b13ce1dce", | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| } | |
| }, | |
| "execution_count": 23, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| "array([0.001, 0.005, 0.01 , 0.048, 0.099, 0.2 , 0.248, 0.301, 0.401,\n", | |
| " 0.5 , 0.6 , 0.7 , 0.75 , 0.8 , 0.9 , 0.95 , 0.98 , 0.99 ,\n", | |
| " 0.995, 0.998, 0.999])" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 23 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "calc_prob(_k, data.size, source='scipy').round(3)" | |
| ], | |
| "metadata": { | |
| "id": "33Ud0MTDb59Q", | |
| "outputId": "a80d8d6f-5ea2-4407-8b3a-120dee4a86a4", | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| } | |
| }, | |
| "execution_count": 24, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| "array([0. , 0.001, 0.002, 0.012, 0.032, 0.083, 0.113, 0.148, 0.225,\n", | |
| " 0.312, 0.413, 0.526, 0.59 , 0.657, 0.807, 0.894, 0.953, 0.974,\n", | |
| " 0.986, 0.994, 0.997])" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 24 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "calc_prob(_k, data.size, source='powell').round(3)" | |
| ], | |
| "metadata": { | |
| "id": "u1z412RCb7MC", | |
| "outputId": "a137c730-871c-4de6-fcb0-8e22e63871bc", | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| } | |
| }, | |
| "execution_count": 25, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| "array([0. , 0.001, 0.002, 0.023, 0.065, 0.165, 0.217, 0.276, 0.391,\n", | |
| " 0.505, 0.619, 0.728, 0.781, 0.831, 0.925, 0.967, 0.988, 0.995,\n", | |
| " 0.998, 0.999, 1. ])" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 25 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "calc_prob(_k, data.size, source='soewarno')" | |
| ], | |
| "metadata": { | |
| "id": "T_cZzfCxcEnx", | |
| "outputId": "819a280a-f792-47ad-ba04-d6517b6e6df5", | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| } | |
| }, | |
| "execution_count": 26, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| "array([0.001, 0.005, 0.01 , 0.048, 0.099, 0.2 , 0.248, 0.301, 0.401,\n", | |
| " 0.5 , 0.6 , 0.7 , 0.75 , 0.8 , 0.9 , 0.95 , 0.98 , 0.99 ,\n", | |
| " 0.995, 0.998, 0.999])" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 26 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "# Changelog\n", | |
| "\n", | |
| "```\n", | |
| "- 20220323 - 1.1.0 - tambah argumen index_name=\"Kala Ulang\" pada fungsi freq_gumbel() untuk penamaan index\n", | |
| "- 20220315 - 1.0.1 - Tambah fungsi `calc_prob(...)`\n", | |
| "- 20220310 - 1.0.0 - Initial\n", | |
| "```\n", | |
| "\n", | |
| "#### Copyright © 2022 [Taruma Sakti Megariansyah](https://taruma.github.io)\n", | |
| "\n", | |
| "Source code in this notebook is licensed under a [MIT License](https://choosealicense.com/licenses/mit/). Data in this notebook is licensed under a [Creative Common Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/). \n" | |
| ], | |
| "metadata": { | |
| "id": "w324QF-g-4HU" | |
| } | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment