2024-10-03 10:47:35 +07:00
|
|
|
|
{
|
|
|
|
|
"cells": [
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 295,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"import numpy as np\n",
|
|
|
|
|
"import pandas as pd\n",
|
|
|
|
|
"import seaborn as sns\n",
|
|
|
|
|
"import matplotlib.pyplot as plt\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# Gamma function\n",
|
|
|
|
|
"from scipy.special import gamma\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# To calculate statistics\n",
|
|
|
|
|
"from scipy.stats import norm\n",
|
|
|
|
|
"from scipy.stats import hmean, trim_mean, iqr, median_abs_deviation, skew, kurtosis\n",
|
|
|
|
|
"from scipy.stats.mstats import gmean, winsorize"
|
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"---"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"Reading and preprocessing data"
|
|
|
|
|
]
|
|
|
|
|
},
|
2024-10-03 10:47:35 +07:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 296,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"DataWhr2024 = pd.read_csv(\"DataWhr2024.csv\")\n",
|
|
|
|
|
"UnM49 = pd.read_csv(\"UnM49.csv\", sep=';')"
|
2024-10-03 10:47:35 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 297,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"UnM49 = UnM49[['Country or Area', 'Sub-region Name', 'Region Name']]\n",
|
|
|
|
|
"UnM49 = UnM49.rename({'Country or Area':'Country name', 'Sub-region Name':'Subregion', 'Region Name':'Continent'}, axis=1)"
|
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 298,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"DataWhr2024.loc[DataWhr2024[\"Country name\"].str.startswith(\"Hong\"), \"Country name\"] = \"Hong Kong\"\n",
|
|
|
|
|
"DataWhr2024.loc[DataWhr2024[\"Country name\"].str.startswith(\"Somaliland\"), \"Country name\"] = \"Somaliland\"\n",
|
|
|
|
|
"DataWhr2024.loc[DataWhr2024[\"Country name\"].str.startswith(\"Taiwan\"), \"Country name\"] = \"Taiwan\""
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 299,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"UnM49.loc[97, \"Country name\"] = \"Bolivia\"\n",
|
|
|
|
|
"UnM49.loc[33, \"Country name\"] = \"Congo (Brazzaville)\"\n",
|
|
|
|
|
"UnM49.loc[34, \"Country name\"] = \"Congo (Kinshasa)\"\n",
|
|
|
|
|
"UnM49.loc[124, \"Country name\"] = \"Hong Kong\"\n",
|
|
|
|
|
"UnM49.loc[125, \"Country name\"] = \"Macao\"\n",
|
|
|
|
|
"UnM49.loc[126, \"Country name\"] = \"North Korea\"\n",
|
|
|
|
|
"UnM49.loc[145, \"Country name\"] = \"Iran\"\n",
|
|
|
|
|
"UnM49.loc[46, \"Country name\"] = \"Ivory Coast\"\n",
|
|
|
|
|
"UnM49.loc[133, \"Country name\"] = \"Laos\"\n",
|
|
|
|
|
"UnM49.loc[129, \"Country name\"] = \"South Korea\"\n",
|
|
|
|
|
"UnM49.loc[173, \"Country name\"] = \"Moldova\"\n",
|
|
|
|
|
"UnM49.loc[217, \"Country name\"] = \"Netherlands\"\n",
|
|
|
|
|
"UnM49.loc[175, \"Country name\"] = \"Russia\"\n",
|
|
|
|
|
"UnM49.loc[164, \"Country name\"] = \"Syria\"\n",
|
|
|
|
|
"UnM49.loc[26, \"Country name\"] = \"Tanzania\"\n",
|
|
|
|
|
"UnM49.loc[116, \"Country name\"] = \"United States\"\n",
|
|
|
|
|
"UnM49.loc[193, \"Country name\"] = \"United Kingdom\"\n",
|
|
|
|
|
"UnM49.loc[111, \"Country name\"] = \"Venezuela\"\n",
|
|
|
|
|
"UnM49.loc[140, \"Country name\"] = \"Vietnam\""
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 300,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"_ = pd.DataFrame(\n",
|
|
|
|
|
" {\n",
|
|
|
|
|
" \"Country name\": [\"Kosovo\", \"Somaliland\", \"Taiwan\"],\n",
|
|
|
|
|
" \"Subregion\": [\"Southern Europe\", \"Sub-Saharan Africa\", \"Eastern Asia\"],\n",
|
|
|
|
|
" \"Continent\": [\"Europe\", \"Africa\", \"Asia\"],\n",
|
|
|
|
|
" }\n",
|
|
|
|
|
")\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"UnM49 = pd.concat([UnM49, _], axis=0)\n",
|
|
|
|
|
"UnM49 = UnM49.reset_index(drop=True)"
|
|
|
|
|
]
|
|
|
|
|
},
|
2024-10-03 10:47:35 +07:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"---"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 301,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"# Data\n",
|
|
|
|
|
"Dat = pd.merge(DataWhr2024, UnM49)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 302,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"# Data of 2023\n",
|
|
|
|
|
"Dat2023 = Dat[Dat['year'] == 2023]\n",
|
|
|
|
|
"Dat2023 = Dat2023.reset_index(drop=True)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 303,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"['Taiwan',\n",
|
|
|
|
|
" 'Tajikistan',\n",
|
|
|
|
|
" 'Tanzania',\n",
|
2024-11-20 18:06:44 +07:00
|
|
|
|
" 'Thailand',\n",
|
|
|
|
|
" 'Togo',\n",
|
|
|
|
|
" 'Trinidad and Tobago',\n",
|
|
|
|
|
" 'Tunisia',\n",
|
|
|
|
|
" 'Turkmenistan',\n",
|
|
|
|
|
" 'Türkiye']"
|
2024-10-03 10:47:35 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 303,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"# Countries that starts with the same letter that your name\n",
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"StartsWith = 'T' # The first letter of your name\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"list(Dat[Dat['Country name'].str.startswith(StartsWith)]['Country name'].unique())"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 304,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"# Data of 2023 from the region selected\n",
|
|
|
|
|
"CountrySelected = 'Iraq' # Change to the country that you selected\n",
|
|
|
|
|
"SubregionSelected = Dat[Dat['Country name']==CountrySelected]['Subregion'].unique()[0]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"DatSelected = Dat2023[Dat2023['Subregion']==SubregionSelected]\n",
|
|
|
|
|
"DatSelected = DatSelected.reset_index(drop=True)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 305,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"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>year</th>\n",
|
|
|
|
|
" <th>Life Ladder</th>\n",
|
|
|
|
|
" <th>Log GDP per capita</th>\n",
|
|
|
|
|
" <th>Social support</th>\n",
|
|
|
|
|
" <th>Healthy life expectancy at birth</th>\n",
|
|
|
|
|
" <th>Freedom to make life choices</th>\n",
|
|
|
|
|
" <th>Generosity</th>\n",
|
|
|
|
|
" <th>Perceptions of corruption</th>\n",
|
|
|
|
|
" <th>Positive affect</th>\n",
|
|
|
|
|
" <th>Negative affect</th>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" </thead>\n",
|
|
|
|
|
" <tbody>\n",
|
|
|
|
|
" <tr>\n",
|
|
|
|
|
" <th>count</th>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <td>138.0</td>\n",
|
|
|
|
|
" <td>138.000000</td>\n",
|
|
|
|
|
" <td>129.000000</td>\n",
|
|
|
|
|
" <td>138.000000</td>\n",
|
|
|
|
|
" <td>135.000000</td>\n",
|
|
|
|
|
" <td>136.000000</td>\n",
|
|
|
|
|
" <td>129.000000</td>\n",
|
|
|
|
|
" <td>131.000000</td>\n",
|
|
|
|
|
" <td>138.000000</td>\n",
|
|
|
|
|
" <td>138.000000</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
|
|
|
|
" <th>mean</th>\n",
|
|
|
|
|
" <td>2023.0</td>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <td>5.620848</td>\n",
|
|
|
|
|
" <td>9.516690</td>\n",
|
|
|
|
|
" <td>0.790978</td>\n",
|
|
|
|
|
" <td>65.188148</td>\n",
|
|
|
|
|
" <td>0.790287</td>\n",
|
|
|
|
|
" <td>0.033597</td>\n",
|
|
|
|
|
" <td>0.721115</td>\n",
|
|
|
|
|
" <td>0.652101</td>\n",
|
|
|
|
|
" <td>0.293428</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
|
|
|
|
" <th>std</th>\n",
|
|
|
|
|
" <td>0.0</td>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <td>1.139482</td>\n",
|
|
|
|
|
" <td>1.152052</td>\n",
|
|
|
|
|
" <td>0.129673</td>\n",
|
|
|
|
|
" <td>5.542482</td>\n",
|
|
|
|
|
" <td>0.120719</td>\n",
|
|
|
|
|
" <td>0.161931</td>\n",
|
|
|
|
|
" <td>0.175695</td>\n",
|
|
|
|
|
" <td>0.109047</td>\n",
|
|
|
|
|
" <td>0.088862</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
|
|
|
|
" <th>min</th>\n",
|
|
|
|
|
" <td>2023.0</td>\n",
|
|
|
|
|
" <td>1.446000</td>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <td>7.076000</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" <td>0.368000</td>\n",
|
|
|
|
|
" <td>52.200000</td>\n",
|
|
|
|
|
" <td>0.228000</td>\n",
|
|
|
|
|
" <td>-0.268000</td>\n",
|
|
|
|
|
" <td>0.153000</td>\n",
|
|
|
|
|
" <td>0.261000</td>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <td>0.111000</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
|
|
|
|
" <th>25%</th>\n",
|
|
|
|
|
" <td>2023.0</td>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <td>4.679750</td>\n",
|
|
|
|
|
" <td>8.620000</td>\n",
|
|
|
|
|
" <td>0.702250</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" <td>60.700000</td>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <td>0.734750</td>\n",
|
|
|
|
|
" <td>-0.071000</td>\n",
|
|
|
|
|
" <td>0.662000</td>\n",
|
|
|
|
|
" <td>0.581250</td>\n",
|
|
|
|
|
" <td>0.229250</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
|
|
|
|
" <th>50%</th>\n",
|
|
|
|
|
" <td>2023.0</td>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <td>5.863000</td>\n",
|
|
|
|
|
" <td>9.637000</td>\n",
|
|
|
|
|
" <td>0.829000</td>\n",
|
|
|
|
|
" <td>66.100000</td>\n",
|
|
|
|
|
" <td>0.803000</td>\n",
|
|
|
|
|
" <td>0.028000</td>\n",
|
|
|
|
|
" <td>0.769000</td>\n",
|
|
|
|
|
" <td>0.668500</td>\n",
|
|
|
|
|
" <td>0.285000</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
|
|
|
|
" <th>75%</th>\n",
|
|
|
|
|
" <td>2023.0</td>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <td>6.487250</td>\n",
|
|
|
|
|
" <td>10.504000</td>\n",
|
|
|
|
|
" <td>0.889750</td>\n",
|
|
|
|
|
" <td>69.600000</td>\n",
|
|
|
|
|
" <td>0.876250</td>\n",
|
|
|
|
|
" <td>0.138000</td>\n",
|
|
|
|
|
" <td>0.838500</td>\n",
|
|
|
|
|
" <td>0.735500</td>\n",
|
|
|
|
|
" <td>0.357500</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
|
|
|
|
" <th>max</th>\n",
|
|
|
|
|
" <td>2023.0</td>\n",
|
|
|
|
|
" <td>7.699000</td>\n",
|
|
|
|
|
" <td>11.676000</td>\n",
|
|
|
|
|
" <td>0.979000</td>\n",
|
|
|
|
|
" <td>74.600000</td>\n",
|
|
|
|
|
" <td>0.965000</td>\n",
|
|
|
|
|
" <td>0.590000</td>\n",
|
|
|
|
|
" <td>0.948000</td>\n",
|
|
|
|
|
" <td>0.843000</td>\n",
|
|
|
|
|
" <td>0.516000</td>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" </tbody>\n",
|
|
|
|
|
"</table>\n",
|
|
|
|
|
"</div>"
|
|
|
|
|
],
|
|
|
|
|
"text/plain": [
|
|
|
|
|
" year Life Ladder Log GDP per capita Social support \\\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"count 138.0 138.000000 129.000000 138.000000 \n",
|
|
|
|
|
"mean 2023.0 5.620848 9.516690 0.790978 \n",
|
|
|
|
|
"std 0.0 1.139482 1.152052 0.129673 \n",
|
|
|
|
|
"min 2023.0 1.446000 7.076000 0.368000 \n",
|
|
|
|
|
"25% 2023.0 4.679750 8.620000 0.702250 \n",
|
|
|
|
|
"50% 2023.0 5.863000 9.637000 0.829000 \n",
|
|
|
|
|
"75% 2023.0 6.487250 10.504000 0.889750 \n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"max 2023.0 7.699000 11.676000 0.979000 \n",
|
|
|
|
|
"\n",
|
|
|
|
|
" Healthy life expectancy at birth Freedom to make life choices \\\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"count 135.000000 136.000000 \n",
|
|
|
|
|
"mean 65.188148 0.790287 \n",
|
|
|
|
|
"std 5.542482 0.120719 \n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"min 52.200000 0.228000 \n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"25% 60.700000 0.734750 \n",
|
|
|
|
|
"50% 66.100000 0.803000 \n",
|
|
|
|
|
"75% 69.600000 0.876250 \n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"max 74.600000 0.965000 \n",
|
|
|
|
|
"\n",
|
|
|
|
|
" Generosity Perceptions of corruption Positive affect Negative affect \n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"count 129.000000 131.000000 138.000000 138.000000 \n",
|
|
|
|
|
"mean 0.033597 0.721115 0.652101 0.293428 \n",
|
|
|
|
|
"std 0.161931 0.175695 0.109047 0.088862 \n",
|
|
|
|
|
"min -0.268000 0.153000 0.261000 0.111000 \n",
|
|
|
|
|
"25% -0.071000 0.662000 0.581250 0.229250 \n",
|
|
|
|
|
"50% 0.028000 0.769000 0.668500 0.285000 \n",
|
|
|
|
|
"75% 0.138000 0.838500 0.735500 0.357500 \n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"max 0.590000 0.948000 0.843000 0.516000 "
|
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 305,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"Dat2023.describe()"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 306,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"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>Country name</th>\n",
|
|
|
|
|
" <th>year</th>\n",
|
|
|
|
|
" <th>Life Ladder</th>\n",
|
|
|
|
|
" <th>Log GDP per capita</th>\n",
|
|
|
|
|
" <th>Social support</th>\n",
|
|
|
|
|
" <th>Healthy life expectancy at birth</th>\n",
|
|
|
|
|
" <th>Freedom to make life choices</th>\n",
|
|
|
|
|
" <th>Generosity</th>\n",
|
|
|
|
|
" <th>Perceptions of corruption</th>\n",
|
|
|
|
|
" <th>Positive affect</th>\n",
|
|
|
|
|
" <th>Negative affect</th>\n",
|
|
|
|
|
" <th>Subregion</th>\n",
|
|
|
|
|
" <th>Continent</th>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" </thead>\n",
|
|
|
|
|
" <tbody>\n",
|
|
|
|
|
" <tr>\n",
|
|
|
|
|
" <th>0</th>\n",
|
|
|
|
|
" <td>Afghanistan</td>\n",
|
|
|
|
|
" <td>2023</td>\n",
|
|
|
|
|
" <td>1.446</td>\n",
|
|
|
|
|
" <td>NaN</td>\n",
|
|
|
|
|
" <td>0.368</td>\n",
|
|
|
|
|
" <td>55.2</td>\n",
|
|
|
|
|
" <td>0.228</td>\n",
|
|
|
|
|
" <td>NaN</td>\n",
|
|
|
|
|
" <td>0.738</td>\n",
|
|
|
|
|
" <td>0.261</td>\n",
|
|
|
|
|
" <td>0.460</td>\n",
|
|
|
|
|
" <td>Southern Asia</td>\n",
|
|
|
|
|
" <td>Asia</td>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
|
|
|
|
" <th>1</th>\n",
|
|
|
|
|
" <td>Albania</td>\n",
|
|
|
|
|
" <td>2023</td>\n",
|
|
|
|
|
" <td>5.445</td>\n",
|
|
|
|
|
" <td>9.689</td>\n",
|
|
|
|
|
" <td>0.691</td>\n",
|
|
|
|
|
" <td>69.2</td>\n",
|
|
|
|
|
" <td>0.872</td>\n",
|
|
|
|
|
" <td>0.068</td>\n",
|
|
|
|
|
" <td>0.855</td>\n",
|
|
|
|
|
" <td>0.597</td>\n",
|
|
|
|
|
" <td>0.314</td>\n",
|
|
|
|
|
" <td>Southern Europe</td>\n",
|
|
|
|
|
" <td>Europe</td>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
|
|
|
|
" <th>2</th>\n",
|
|
|
|
|
" <td>Argentina</td>\n",
|
|
|
|
|
" <td>2023</td>\n",
|
|
|
|
|
" <td>6.393</td>\n",
|
|
|
|
|
" <td>9.994</td>\n",
|
|
|
|
|
" <td>0.892</td>\n",
|
|
|
|
|
" <td>67.3</td>\n",
|
|
|
|
|
" <td>0.832</td>\n",
|
|
|
|
|
" <td>-0.129</td>\n",
|
|
|
|
|
" <td>0.846</td>\n",
|
|
|
|
|
" <td>0.720</td>\n",
|
|
|
|
|
" <td>0.301</td>\n",
|
|
|
|
|
" <td>Latin America and the Caribbean</td>\n",
|
|
|
|
|
" <td>Americas</td>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
|
|
|
|
" <th>3</th>\n",
|
|
|
|
|
" <td>Armenia</td>\n",
|
|
|
|
|
" <td>2023</td>\n",
|
|
|
|
|
" <td>5.679</td>\n",
|
|
|
|
|
" <td>9.730</td>\n",
|
|
|
|
|
" <td>0.819</td>\n",
|
|
|
|
|
" <td>68.2</td>\n",
|
|
|
|
|
" <td>0.819</td>\n",
|
|
|
|
|
" <td>-0.179</td>\n",
|
|
|
|
|
" <td>0.681</td>\n",
|
|
|
|
|
" <td>0.575</td>\n",
|
|
|
|
|
" <td>0.423</td>\n",
|
|
|
|
|
" <td>Western Asia</td>\n",
|
|
|
|
|
" <td>Asia</td>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
|
|
|
|
" <th>4</th>\n",
|
|
|
|
|
" <td>Australia</td>\n",
|
|
|
|
|
" <td>2023</td>\n",
|
|
|
|
|
" <td>7.025</td>\n",
|
|
|
|
|
" <td>10.846</td>\n",
|
|
|
|
|
" <td>0.896</td>\n",
|
|
|
|
|
" <td>71.2</td>\n",
|
|
|
|
|
" <td>0.876</td>\n",
|
|
|
|
|
" <td>0.187</td>\n",
|
|
|
|
|
" <td>0.482</td>\n",
|
|
|
|
|
" <td>0.731</td>\n",
|
|
|
|
|
" <td>0.248</td>\n",
|
|
|
|
|
" <td>Australia and New Zealand</td>\n",
|
|
|
|
|
" <td>Oceania</td>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
|
|
|
|
" <th>...</th>\n",
|
|
|
|
|
" <td>...</td>\n",
|
|
|
|
|
" <td>...</td>\n",
|
|
|
|
|
" <td>...</td>\n",
|
|
|
|
|
" <td>...</td>\n",
|
|
|
|
|
" <td>...</td>\n",
|
|
|
|
|
" <td>...</td>\n",
|
|
|
|
|
" <td>...</td>\n",
|
|
|
|
|
" <td>...</td>\n",
|
|
|
|
|
" <td>...</td>\n",
|
|
|
|
|
" <td>...</td>\n",
|
|
|
|
|
" <td>...</td>\n",
|
|
|
|
|
" <td>...</td>\n",
|
|
|
|
|
" <td>...</td>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <th>133</th>\n",
|
|
|
|
|
" <td>Venezuela</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" <td>2023</td>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <td>5.765</td>\n",
|
|
|
|
|
" <td>NaN</td>\n",
|
|
|
|
|
" <td>0.885</td>\n",
|
|
|
|
|
" <td>63.7</td>\n",
|
|
|
|
|
" <td>0.757</td>\n",
|
|
|
|
|
" <td>NaN</td>\n",
|
|
|
|
|
" <td>0.825</td>\n",
|
|
|
|
|
" <td>0.758</td>\n",
|
|
|
|
|
" <td>0.300</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" <td>Latin America and the Caribbean</td>\n",
|
|
|
|
|
" <td>Americas</td>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <th>134</th>\n",
|
|
|
|
|
" <td>Vietnam</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" <td>2023</td>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <td>6.325</td>\n",
|
|
|
|
|
" <td>9.392</td>\n",
|
|
|
|
|
" <td>0.845</td>\n",
|
|
|
|
|
" <td>65.7</td>\n",
|
|
|
|
|
" <td>0.956</td>\n",
|
|
|
|
|
" <td>-0.159</td>\n",
|
|
|
|
|
" <td>0.655</td>\n",
|
|
|
|
|
" <td>0.710</td>\n",
|
|
|
|
|
" <td>0.120</td>\n",
|
|
|
|
|
" <td>South-eastern Asia</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" <td>Asia</td>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <th>135</th>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" <td>Yemen</td>\n",
|
|
|
|
|
" <td>2023</td>\n",
|
|
|
|
|
" <td>3.532</td>\n",
|
|
|
|
|
" <td>NaN</td>\n",
|
|
|
|
|
" <td>0.825</td>\n",
|
|
|
|
|
" <td>56.6</td>\n",
|
|
|
|
|
" <td>0.583</td>\n",
|
|
|
|
|
" <td>NaN</td>\n",
|
|
|
|
|
" <td>0.771</td>\n",
|
|
|
|
|
" <td>0.447</td>\n",
|
|
|
|
|
" <td>0.341</td>\n",
|
|
|
|
|
" <td>Western Asia</td>\n",
|
|
|
|
|
" <td>Asia</td>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <th>136</th>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" <td>Zambia</td>\n",
|
|
|
|
|
" <td>2023</td>\n",
|
|
|
|
|
" <td>3.686</td>\n",
|
|
|
|
|
" <td>8.115</td>\n",
|
|
|
|
|
" <td>0.664</td>\n",
|
|
|
|
|
" <td>56.1</td>\n",
|
|
|
|
|
" <td>0.854</td>\n",
|
|
|
|
|
" <td>0.092</td>\n",
|
|
|
|
|
" <td>0.814</td>\n",
|
|
|
|
|
" <td>0.653</td>\n",
|
|
|
|
|
" <td>0.359</td>\n",
|
|
|
|
|
" <td>Sub-Saharan Africa</td>\n",
|
|
|
|
|
" <td>Africa</td>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" <tr>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <th>137</th>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" <td>Zimbabwe</td>\n",
|
|
|
|
|
" <td>2023</td>\n",
|
|
|
|
|
" <td>3.572</td>\n",
|
|
|
|
|
" <td>7.679</td>\n",
|
|
|
|
|
" <td>0.694</td>\n",
|
|
|
|
|
" <td>55.0</td>\n",
|
|
|
|
|
" <td>0.735</td>\n",
|
|
|
|
|
" <td>-0.069</td>\n",
|
|
|
|
|
" <td>0.757</td>\n",
|
|
|
|
|
" <td>0.610</td>\n",
|
|
|
|
|
" <td>0.179</td>\n",
|
|
|
|
|
" <td>Sub-Saharan Africa</td>\n",
|
|
|
|
|
" <td>Africa</td>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" </tbody>\n",
|
|
|
|
|
"</table>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"<p>138 rows × 13 columns</p>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"</div>"
|
|
|
|
|
],
|
|
|
|
|
"text/plain": [
|
|
|
|
|
" Country name year Life Ladder Log GDP per capita Social support \\\n",
|
|
|
|
|
"0 Afghanistan 2023 1.446 NaN 0.368 \n",
|
|
|
|
|
"1 Albania 2023 5.445 9.689 0.691 \n",
|
|
|
|
|
"2 Argentina 2023 6.393 9.994 0.892 \n",
|
|
|
|
|
"3 Armenia 2023 5.679 9.730 0.819 \n",
|
|
|
|
|
"4 Australia 2023 7.025 10.846 0.896 \n",
|
|
|
|
|
".. ... ... ... ... ... \n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"133 Venezuela 2023 5.765 NaN 0.885 \n",
|
|
|
|
|
"134 Vietnam 2023 6.325 9.392 0.845 \n",
|
|
|
|
|
"135 Yemen 2023 3.532 NaN 0.825 \n",
|
|
|
|
|
"136 Zambia 2023 3.686 8.115 0.664 \n",
|
|
|
|
|
"137 Zimbabwe 2023 3.572 7.679 0.694 \n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"\n",
|
|
|
|
|
" Healthy life expectancy at birth Freedom to make life choices \\\n",
|
|
|
|
|
"0 55.2 0.228 \n",
|
|
|
|
|
"1 69.2 0.872 \n",
|
|
|
|
|
"2 67.3 0.832 \n",
|
|
|
|
|
"3 68.2 0.819 \n",
|
|
|
|
|
"4 71.2 0.876 \n",
|
|
|
|
|
".. ... ... \n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"133 63.7 0.757 \n",
|
|
|
|
|
"134 65.7 0.956 \n",
|
|
|
|
|
"135 56.6 0.583 \n",
|
|
|
|
|
"136 56.1 0.854 \n",
|
|
|
|
|
"137 55.0 0.735 \n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"\n",
|
|
|
|
|
" Generosity Perceptions of corruption Positive affect Negative affect \\\n",
|
|
|
|
|
"0 NaN 0.738 0.261 0.460 \n",
|
|
|
|
|
"1 0.068 0.855 0.597 0.314 \n",
|
|
|
|
|
"2 -0.129 0.846 0.720 0.301 \n",
|
|
|
|
|
"3 -0.179 0.681 0.575 0.423 \n",
|
|
|
|
|
"4 0.187 0.482 0.731 0.248 \n",
|
|
|
|
|
".. ... ... ... ... \n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"133 NaN 0.825 0.758 0.300 \n",
|
|
|
|
|
"134 -0.159 0.655 0.710 0.120 \n",
|
|
|
|
|
"135 NaN 0.771 0.447 0.341 \n",
|
|
|
|
|
"136 0.092 0.814 0.653 0.359 \n",
|
|
|
|
|
"137 -0.069 0.757 0.610 0.179 \n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"\n",
|
|
|
|
|
" Subregion Continent \n",
|
|
|
|
|
"0 Southern Asia Asia \n",
|
|
|
|
|
"1 Southern Europe Europe \n",
|
|
|
|
|
"2 Latin America and the Caribbean Americas \n",
|
|
|
|
|
"3 Western Asia Asia \n",
|
|
|
|
|
"4 Australia and New Zealand Oceania \n",
|
|
|
|
|
".. ... ... \n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"133 Latin America and the Caribbean Americas \n",
|
|
|
|
|
"134 South-eastern Asia Asia \n",
|
|
|
|
|
"135 Western Asia Asia \n",
|
|
|
|
|
"136 Sub-Saharan Africa Africa \n",
|
|
|
|
|
"137 Sub-Saharan Africa Africa \n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"[138 rows x 13 columns]"
|
2024-10-03 10:47:35 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 306,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"Dat2023"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 307,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"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>Country name</th>\n",
|
|
|
|
|
" <th>year</th>\n",
|
|
|
|
|
" <th>Life Ladder</th>\n",
|
|
|
|
|
" <th>Log GDP per capita</th>\n",
|
|
|
|
|
" <th>Social support</th>\n",
|
|
|
|
|
" <th>Healthy life expectancy at birth</th>\n",
|
|
|
|
|
" <th>Freedom to make life choices</th>\n",
|
|
|
|
|
" <th>Generosity</th>\n",
|
|
|
|
|
" <th>Perceptions of corruption</th>\n",
|
|
|
|
|
" <th>Positive affect</th>\n",
|
|
|
|
|
" <th>Negative affect</th>\n",
|
|
|
|
|
" <th>Subregion</th>\n",
|
|
|
|
|
" <th>Continent</th>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" </thead>\n",
|
|
|
|
|
" <tbody>\n",
|
|
|
|
|
" <tr>\n",
|
2024-11-19 23:03:48 +07:00
|
|
|
|
" <th>0</th>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" <td>Afghanistan</td>\n",
|
2024-11-19 23:03:48 +07:00
|
|
|
|
" <td>2023</td>\n",
|
|
|
|
|
" <td>1.446</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" <td>NaN</td>\n",
|
|
|
|
|
" <td>0.368</td>\n",
|
2024-11-19 23:03:48 +07:00
|
|
|
|
" <td>55.2</td>\n",
|
|
|
|
|
" <td>0.228</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" <td>NaN</td>\n",
|
2024-11-19 23:03:48 +07:00
|
|
|
|
" <td>0.738</td>\n",
|
|
|
|
|
" <td>0.261</td>\n",
|
|
|
|
|
" <td>0.46</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" <td>Southern Asia</td>\n",
|
|
|
|
|
" <td>Asia</td>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" </tbody>\n",
|
|
|
|
|
"</table>\n",
|
|
|
|
|
"</div>"
|
|
|
|
|
],
|
|
|
|
|
"text/plain": [
|
2024-11-19 23:03:48 +07:00
|
|
|
|
" Country name year Life Ladder Log GDP per capita Social support \\\n",
|
|
|
|
|
"0 Afghanistan 2023 1.446 NaN 0.368 \n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"\n",
|
2024-11-19 23:03:48 +07:00
|
|
|
|
" Healthy life expectancy at birth Freedom to make life choices Generosity \\\n",
|
|
|
|
|
"0 55.2 0.228 NaN \n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"\n",
|
2024-11-19 23:03:48 +07:00
|
|
|
|
" Perceptions of corruption Positive affect Negative affect Subregion \\\n",
|
|
|
|
|
"0 0.738 0.261 0.46 Southern Asia \n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"\n",
|
2024-11-19 23:03:48 +07:00
|
|
|
|
" Continent \n",
|
|
|
|
|
"0 Asia "
|
2024-10-03 10:47:35 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 307,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"Dat2023.loc[Dat2023[\"Life Ladder\"] == Dat2023[\"Life Ladder\"].min()]"
|
2024-10-03 10:47:35 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 308,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"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>Country name</th>\n",
|
|
|
|
|
" <th>year</th>\n",
|
|
|
|
|
" <th>Life Ladder</th>\n",
|
|
|
|
|
" <th>Log GDP per capita</th>\n",
|
|
|
|
|
" <th>Social support</th>\n",
|
|
|
|
|
" <th>Healthy life expectancy at birth</th>\n",
|
|
|
|
|
" <th>Freedom to make life choices</th>\n",
|
|
|
|
|
" <th>Generosity</th>\n",
|
|
|
|
|
" <th>Perceptions of corruption</th>\n",
|
|
|
|
|
" <th>Positive affect</th>\n",
|
|
|
|
|
" <th>Negative affect</th>\n",
|
|
|
|
|
" <th>Subregion</th>\n",
|
|
|
|
|
" <th>Continent</th>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" </thead>\n",
|
|
|
|
|
" <tbody>\n",
|
|
|
|
|
" <tr>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <th>38</th>\n",
|
2024-11-19 23:03:48 +07:00
|
|
|
|
" <td>Finland</td>\n",
|
|
|
|
|
" <td>2023</td>\n",
|
|
|
|
|
" <td>7.699</td>\n",
|
|
|
|
|
" <td>10.808</td>\n",
|
|
|
|
|
" <td>0.947</td>\n",
|
|
|
|
|
" <td>71.3</td>\n",
|
|
|
|
|
" <td>0.943</td>\n",
|
|
|
|
|
" <td>-0.001</td>\n",
|
|
|
|
|
" <td>0.185</td>\n",
|
|
|
|
|
" <td>0.717</td>\n",
|
|
|
|
|
" <td>0.173</td>\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
" <td>Northern Europe</td>\n",
|
|
|
|
|
" <td>Europe</td>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" </tbody>\n",
|
|
|
|
|
"</table>\n",
|
|
|
|
|
"</div>"
|
|
|
|
|
],
|
|
|
|
|
"text/plain": [
|
2024-11-19 23:03:48 +07:00
|
|
|
|
" Country name year Life Ladder Log GDP per capita Social support \\\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"38 Finland 2023 7.699 10.808 0.947 \n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"\n",
|
2024-11-19 23:03:48 +07:00
|
|
|
|
" Healthy life expectancy at birth Freedom to make life choices \\\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"38 71.3 0.943 \n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"\n",
|
2024-11-19 23:03:48 +07:00
|
|
|
|
" Generosity Perceptions of corruption Positive affect Negative affect \\\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"38 -0.001 0.185 0.717 0.173 \n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"\n",
|
2024-11-19 23:03:48 +07:00
|
|
|
|
" Subregion Continent \n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"38 Northern Europe Europe "
|
2024-10-03 10:47:35 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 308,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"Dat2023.loc[Dat2023[\"Life Ladder\"] == Dat2023[\"Life Ladder\"].max()]"
|
2024-10-03 10:47:35 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 309,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"avg_health = Dat2023[\"Healthy life expectancy at birth\"].median()"
|
2024-10-03 10:47:35 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 310,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"name": "stdout",
|
|
|
|
|
"output_type": "stream",
|
|
|
|
|
"text": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"66.1\n"
|
2024-10-03 10:47:35 +07:00
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"print(avg_health)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 311,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"np.float64(0.22925)"
|
2024-10-03 10:47:35 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 311,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"#p = [0.25, 0.5, 0.75]\n",
|
|
|
|
|
"np.quantile(Dat2023[\"Negative affect\"], 0.25)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"#Dat[\"Negative affect\"]"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 312,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"array([4.647 , 5.449 , 6.3235])"
|
2024-10-03 10:47:35 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 312,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"p = [0.25, 0.5, 0.75]\n",
|
|
|
|
|
"np.quantile(Dat[\"Life Ladder\"], p)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 313,
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"name": "stdout",
|
|
|
|
|
"output_type": "stream",
|
|
|
|
|
"text": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"5.8629999999999995\n",
|
|
|
|
|
"5.620847826086956\n",
|
|
|
|
|
"5.484781886942988\n",
|
|
|
|
|
"5.310494263379958\n",
|
|
|
|
|
"5.690625\n",
|
|
|
|
|
"5.768428571428572\n",
|
|
|
|
|
"5.620847826086956\n"
|
2024-10-03 10:47:35 +07:00
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"ll = Dat2023[\"Life Ladder\"]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Mean = ll.mean()\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"\n",
|
|
|
|
|
"print(ll.median())\n",
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"print(Mean)\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"print(gmean(ll))\n",
|
|
|
|
|
"print(hmean(ll))\n",
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"print(trim_mean(ll, 0.1))\n",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"print(trim_mean(ll, 0.25))\n",
|
|
|
|
|
"print(winsorize(ll).mean())"
|
|
|
|
|
]
|
2024-11-19 23:03:48 +07:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 314,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"name": "stdout",
|
|
|
|
|
"output_type": "stream",
|
|
|
|
|
"text": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"1.1353457170100019\n",
|
|
|
|
|
"1.1394817806787827\n",
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"6.253\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"1.8074999999999992\n",
|
|
|
|
|
"0.7935000000000008\n",
|
|
|
|
|
"0.9389300567107751\n"
|
2024-11-19 23:03:48 +07:00
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"S2Biased = np.var(ll)\n",
|
|
|
|
|
"S2Unbiased = np.var(ll, ddof=1)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"S1 = np.sqrt(S2Biased)\n",
|
|
|
|
|
"S2 = np.sqrt(S2Unbiased)\n",
|
|
|
|
|
"R = ll.max() - ll.min()\n",
|
|
|
|
|
"IQR = iqr(ll)\n",
|
|
|
|
|
"MAD = median_abs_deviation(ll)\n",
|
|
|
|
|
"AAD = abs(ll-ll.mean()).mean()\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"print(S1)\n",
|
|
|
|
|
"print(S2)\n",
|
|
|
|
|
"print(R)\n",
|
|
|
|
|
"print(IQR)\n",
|
|
|
|
|
"print(MAD)\n",
|
|
|
|
|
"print(AAD)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 315,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"def an(n):\n",
|
|
|
|
|
" return np.sqrt((n-1)/2) * gamma((n-1)/2) / gamma(n/2)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"def c4(n):\n",
|
|
|
|
|
" return 1/an(n)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# d2 for n in 2,...,25\n",
|
|
|
|
|
"d2 = {2:1.128, 3:1.693, 4:2.059, 5:2.326, 6:2.534, 7:2.704, 8:2.847, 9:2.970, 10:3.078, 11:3.173, 12:3.258, 13:3.336, 14:3.407, 15:3.472, 16:3.532, 17:3.588, 18:3.640, 19:3.689, 20:3.735, 21:3.778, 22:3.819, 23:3.858, 24:3.895, 25:3.931}"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 316,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"name": "stdout",
|
|
|
|
|
"output_type": "stream",
|
|
|
|
|
"text": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"138\n",
|
|
|
|
|
"0.9981768626225431\n"
|
2024-11-19 23:03:48 +07:00
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"N = len(ll)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"print(N)\n",
|
|
|
|
|
"print(c4(N))"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 317,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"name": "stdout",
|
|
|
|
|
"output_type": "stream",
|
|
|
|
|
"text": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"1.1415630068653209\n",
|
|
|
|
|
"1.3399017549744372\n",
|
|
|
|
|
"1.1764448603841964\n",
|
|
|
|
|
"1.1767743140260587\n"
|
2024-11-19 23:03:48 +07:00
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"sigma_1 = S2 / c4(N)\n",
|
|
|
|
|
"#sigma_2 = R / d2[N]\n",
|
|
|
|
|
"sigma_3 = IQR / (2 * norm.ppf(0.75))\n",
|
|
|
|
|
"sigma_4 = MAD / norm.ppf(0.75)\n",
|
|
|
|
|
"sigma_5 = AAD * np.sqrt(np.pi/2)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"print(sigma_1)\n",
|
|
|
|
|
"#print(sigma_2)\n",
|
|
|
|
|
"print(sigma_3)\n",
|
|
|
|
|
"print(sigma_4)\n",
|
|
|
|
|
"print(sigma_5)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 318,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"m2 = S2Biased\n",
|
|
|
|
|
"m3 = ((ll-Mean)**3).mean()\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"k2 = S2Unbiased\n",
|
|
|
|
|
"k3 = N**2 / ((N-1)*(N-2))*m3"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 319,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"g1_byhand = m3 / m2**(3/2)\n",
|
|
|
|
|
"g1 = skew(ll)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 320,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"(np.float64(-0.6323), np.float64(-0.6323))"
|
2024-11-19 23:03:48 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 320,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"g1_byhand.round(4), g1.round(4)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 321,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"G1_byhand = k3 / k2**(3/2)\n",
|
|
|
|
|
"G1 = skew(ll, bias=False)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 322,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"(np.float64(-0.6393), np.float64(-0.6393))"
|
2024-11-19 23:03:48 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 322,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"G1_byhand.round(4), G1.round(4)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 323,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"m4 = ((ll-Mean)**4).mean()\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"k4 = N**2*((N+1)*m4 - 3*(N-1)*m2**2) / ((N-1)*(N-2)*(N-3))"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"Coefficient of kurtosis based on central moments"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 324,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"g2_byhand = m4/m2**2\n",
|
|
|
|
|
"g2 = kurtosis(ll, fisher=False)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 325,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"(np.float64(3.1173), np.float64(3.1173))"
|
2024-11-19 23:03:48 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 325,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
2024-11-19 23:04:11 +07:00
|
|
|
|
"output_type": "execute_result"
|
2024-11-19 23:03:48 +07:00
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"g2_byhand.round(4), g2.round(4)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 326,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
2024-11-19 23:04:11 +07:00
|
|
|
|
"outputs": [],
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"source": [
|
|
|
|
|
"G2_byhand = k4/k2**2 + 3\n",
|
|
|
|
|
"G2 = kurtosis(ll, fisher=False, bias=False)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 327,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"(np.float64(3.1664), np.float64(3.1664))"
|
2024-11-19 23:03:48 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 327,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
2024-11-19 23:04:11 +07:00
|
|
|
|
"output_type": "execute_result"
|
2024-11-19 23:03:48 +07:00
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"G2_byhand.round(4), G2.round(4)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 328,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
2024-11-19 23:04:11 +07:00
|
|
|
|
"outputs": [],
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"source": [
|
|
|
|
|
"g2_excess_byhand = g2_byhand - 3\n",
|
|
|
|
|
"g2_excess = kurtosis(ll)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 329,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"(np.float64(0.1173), np.float64(0.1173))"
|
2024-11-19 23:03:48 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 329,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
2024-11-19 23:04:11 +07:00
|
|
|
|
"output_type": "execute_result"
|
2024-11-19 23:03:48 +07:00
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"g2_excess_byhand.round(4), g2_excess.round(4)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 330,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"G2_excess_byhand = G2_byhand - 3\n",
|
|
|
|
|
"G2_excess = kurtosis(ll, bias=False)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 331,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"(np.float64(0.1664), np.float64(0.1664))"
|
2024-11-19 23:03:48 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 331,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"G2_excess_byhand.round(4), G2_excess.round(4)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"# 7th question"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 332,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"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>Country name</th>\n",
|
|
|
|
|
" <th>year</th>\n",
|
|
|
|
|
" <th>Life Ladder</th>\n",
|
|
|
|
|
" <th>Log GDP per capita</th>\n",
|
|
|
|
|
" <th>Social support</th>\n",
|
|
|
|
|
" <th>Healthy life expectancy at birth</th>\n",
|
|
|
|
|
" <th>Freedom to make life choices</th>\n",
|
|
|
|
|
" <th>Generosity</th>\n",
|
|
|
|
|
" <th>Perceptions of corruption</th>\n",
|
|
|
|
|
" <th>Positive affect</th>\n",
|
|
|
|
|
" <th>Negative affect</th>\n",
|
|
|
|
|
" <th>Subregion</th>\n",
|
|
|
|
|
" <th>Continent</th>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" </thead>\n",
|
|
|
|
|
" <tbody>\n",
|
|
|
|
|
" <tr>\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
" <th>122</th>\n",
|
2024-11-20 18:06:44 +07:00
|
|
|
|
" <td>Thailand</td>\n",
|
|
|
|
|
" <td>2023</td>\n",
|
|
|
|
|
" <td>6.282</td>\n",
|
|
|
|
|
" <td>9.807</td>\n",
|
|
|
|
|
" <td>0.873</td>\n",
|
|
|
|
|
" <td>68.6</td>\n",
|
|
|
|
|
" <td>0.926</td>\n",
|
|
|
|
|
" <td>0.338</td>\n",
|
|
|
|
|
" <td>0.889</td>\n",
|
|
|
|
|
" <td>0.811</td>\n",
|
|
|
|
|
" <td>0.217</td>\n",
|
|
|
|
|
" <td>South-eastern Asia</td>\n",
|
|
|
|
|
" <td>Asia</td>\n",
|
|
|
|
|
" </tr>\n",
|
|
|
|
|
" </tbody>\n",
|
|
|
|
|
"</table>\n",
|
|
|
|
|
"</div>"
|
|
|
|
|
],
|
|
|
|
|
"text/plain": [
|
|
|
|
|
" Country name year Life Ladder Log GDP per capita Social support \\\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"122 Thailand 2023 6.282 9.807 0.873 \n",
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"\n",
|
|
|
|
|
" Healthy life expectancy at birth Freedom to make life choices \\\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"122 68.6 0.926 \n",
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"\n",
|
|
|
|
|
" Generosity Perceptions of corruption Positive affect Negative affect \\\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"122 0.338 0.889 0.811 0.217 \n",
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"\n",
|
|
|
|
|
" Subregion Continent \n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"122 South-eastern Asia Asia "
|
2024-11-20 18:06:44 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 332,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"Dat2023.loc[Dat2023[\"Country name\"] == \"Thailand\"]"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 333,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"# Data of 2023 from the region selected\n",
|
|
|
|
|
"CountrySelected = 'Thailand' # Change to the country that you selected\n",
|
|
|
|
|
"SubregionSelected = Dat[Dat['Country name']==CountrySelected]['Subregion'].unique()[0]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"DatSelected = Dat2023[Dat2023['Subregion']==SubregionSelected]\n",
|
|
|
|
|
"DatSelected = DatSelected.reset_index(drop=True)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 334,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"array([0.9 , 0.926, 0.956])"
|
2024-11-20 18:06:44 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 334,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"p = [0.25, 0.5, 0.75]\n",
|
|
|
|
|
"np.quantile(DatSelected[\"Freedom to make life choices\"], p)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 335,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"name": "stdout",
|
|
|
|
|
"output_type": "stream",
|
|
|
|
|
"text": [
|
|
|
|
|
"0.926\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"0.8999999999999999\n",
|
|
|
|
|
"0.8960830560432489\n",
|
|
|
|
|
"0.891676454482847\n",
|
|
|
|
|
"0.8999999999999999\n",
|
|
|
|
|
"0.9236000000000001\n",
|
|
|
|
|
"0.8999999999999999\n"
|
2024-11-20 18:06:44 +07:00
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"ll = DatSelected[\"Freedom to make life choices\"]\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Mean = ll.mean()\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"print(ll.median())\n",
|
|
|
|
|
"print(Mean)\n",
|
|
|
|
|
"print(gmean(ll))\n",
|
|
|
|
|
"print(hmean(ll))\n",
|
|
|
|
|
"print(trim_mean(ll, 0.1))\n",
|
|
|
|
|
"print(trim_mean(ll, 0.25))\n",
|
|
|
|
|
"print(winsorize(ll).mean())"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 336,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"name": "stdout",
|
|
|
|
|
"output_type": "stream",
|
|
|
|
|
"text": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"0.07912297039699942\n",
|
|
|
|
|
"0.08392258337301112\n",
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"0.27\n",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"0.05599999999999994\n",
|
|
|
|
|
"0.029999999999999916\n",
|
|
|
|
|
"0.05422222222222228\n"
|
2024-11-20 18:06:44 +07:00
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"S2Biased = np.var(ll)\n",
|
|
|
|
|
"S2Unbiased = np.var(ll, ddof=1)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"S1 = np.sqrt(S2Biased)\n",
|
|
|
|
|
"S2 = np.sqrt(S2Unbiased)\n",
|
|
|
|
|
"R = ll.max() - ll.min()\n",
|
|
|
|
|
"IQR = iqr(ll)\n",
|
|
|
|
|
"MAD = median_abs_deviation(ll)\n",
|
|
|
|
|
"AAD = abs(ll-ll.mean()).mean()\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"print(S1)\n",
|
|
|
|
|
"print(S2)\n",
|
|
|
|
|
"print(R)\n",
|
|
|
|
|
"print(IQR)\n",
|
|
|
|
|
"print(MAD)\n",
|
|
|
|
|
"print(AAD)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 337,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"def an(n):\n",
|
|
|
|
|
" return np.sqrt((n-1)/2) * gamma((n-1)/2) / gamma(n/2)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"def c4(n):\n",
|
|
|
|
|
" return 1/an(n)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"# d2 for n in 2,...,25\n",
|
|
|
|
|
"d2 = {2:1.128, 3:1.693, 4:2.059, 5:2.326, 6:2.534, 7:2.704, 8:2.847, 9:2.970, 10:3.078, 11:3.173, 12:3.258, 13:3.336, 14:3.407, 15:3.472, 16:3.532, 17:3.588, 18:3.640, 19:3.689, 20:3.735, 21:3.778, 22:3.819, 23:3.858, 24:3.895, 25:3.931}"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 338,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"name": "stdout",
|
|
|
|
|
"output_type": "stream",
|
|
|
|
|
"text": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"9\n",
|
|
|
|
|
"0.9693106997139541\n"
|
2024-11-20 18:06:44 +07:00
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"N = len(ll)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"print(N)\n",
|
|
|
|
|
"print(c4(N))"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 339,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"name": "stdout",
|
|
|
|
|
"output_type": "stream",
|
|
|
|
|
"text": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"0.08657965232177553\n",
|
|
|
|
|
"0.04151286211815681\n",
|
|
|
|
|
"0.044478066555167936\n",
|
|
|
|
|
"0.06795747766777387\n"
|
2024-11-20 18:06:44 +07:00
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"sigma_1 = S2 / c4(N)\n",
|
|
|
|
|
"#sigma_2 = R / d2[N]\n",
|
|
|
|
|
"sigma_3 = IQR / (2 * norm.ppf(0.75))\n",
|
|
|
|
|
"sigma_4 = MAD / norm.ppf(0.75)\n",
|
|
|
|
|
"sigma_5 = AAD * np.sqrt(np.pi/2)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"print(sigma_1)\n",
|
|
|
|
|
"#print(sigma_2)\n",
|
|
|
|
|
"print(sigma_3)\n",
|
|
|
|
|
"print(sigma_4)\n",
|
|
|
|
|
"print(sigma_5)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 340,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"m2 = S2Biased\n",
|
|
|
|
|
"m3 = ((ll-Mean)**3).mean()\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"k2 = S2Unbiased\n",
|
|
|
|
|
"k3 = N**2 / ((N-1)*(N-2))*m3"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 341,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"g1_byhand = m3 / m2**(3/2)\n",
|
|
|
|
|
"g1 = skew(ll)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 342,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"(np.float64(-1.7826), np.float64(-1.7826))"
|
2024-11-20 18:06:44 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 342,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"g1_byhand.round(4), g1.round(4)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 343,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"G1_byhand = k3 / k2**(3/2)\n",
|
|
|
|
|
"G1 = skew(ll, bias=False)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 344,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"(np.float64(-2.1608), np.float64(-2.1608))"
|
2024-11-20 18:06:44 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 344,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"G1_byhand.round(4), G1.round(4)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 345,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"m4 = ((ll-Mean)**4).mean()\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"k4 = N**2*((N+1)*m4 - 3*(N-1)*m2**2) / ((N-1)*(N-2)*(N-3))"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"Coefficient of kurtosis based on central moments"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 346,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"g2_byhand = m4/m2**2\n",
|
|
|
|
|
"g2 = kurtosis(ll, fisher=False)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 347,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"(np.float64(5.1354), np.float64(5.1354))"
|
2024-11-20 18:06:44 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 347,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"g2_byhand.round(4), g2.round(4)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 348,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"G2_byhand = k4/k2**2 + 3\n",
|
|
|
|
|
"G2 = kurtosis(ll, fisher=False, bias=False)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 349,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"(np.float64(8.2103), np.float64(8.2103))"
|
2024-11-20 18:06:44 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 349,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"G2_byhand.round(4), G2.round(4)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 350,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"g2_excess_byhand = g2_byhand - 3\n",
|
|
|
|
|
"g2_excess = kurtosis(ll)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 351,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"(np.float64(2.1354), np.float64(2.1354))"
|
2024-11-20 18:06:44 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 351,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"g2_excess_byhand.round(4), g2_excess.round(4)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 352,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"G2_excess_byhand = G2_byhand - 3\n",
|
|
|
|
|
"G2_excess = kurtosis(ll, bias=False)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 353,
|
2024-11-20 18:06:44 +07:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"(np.float64(5.2103), np.float64(5.2103))"
|
2024-11-20 18:06:44 +07:00
|
|
|
|
]
|
|
|
|
|
},
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"execution_count": 353,
|
2024-11-19 23:03:48 +07:00
|
|
|
|
"metadata": {},
|
2024-11-19 23:04:11 +07:00
|
|
|
|
"output_type": "execute_result"
|
2024-11-19 23:03:48 +07:00
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"G2_excess_byhand.round(4), G2_excess.round(4)"
|
|
|
|
|
]
|
2024-10-03 10:47:35 +07:00
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"metadata": {
|
|
|
|
|
"kernelspec": {
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"display_name": "Python 3",
|
2024-10-03 10:47:35 +07:00
|
|
|
|
"language": "python",
|
|
|
|
|
"name": "python3"
|
|
|
|
|
},
|
|
|
|
|
"language_info": {
|
|
|
|
|
"codemirror_mode": {
|
|
|
|
|
"name": "ipython",
|
|
|
|
|
"version": 3
|
|
|
|
|
},
|
|
|
|
|
"file_extension": ".py",
|
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
|
"name": "python",
|
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
|
"pygments_lexer": "ipython3",
|
2024-11-22 21:56:52 +07:00
|
|
|
|
"version": "3.12.6"
|
2024-10-03 10:47:35 +07:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"nbformat": 4,
|
|
|
|
|
"nbformat_minor": 2
|
|
|
|
|
}
|