{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "cb048d16-7e90-4a89-82d1-c87466caaea0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Area weight for q0.05: 0.1500\n", "Area weight for q0.25: 0.2250\n", "Area weight for q0.5: 0.2500\n", "Area weight for q0.75: 0.2250\n", "Area weight for q0.95: 0.1500\n" ] } ], "source": [ "from scipy.stats import norm\n", "\n", "# Function to calculate area weight between two quantiles\n", "def calculate_area_weight(lower_quantile, upper_quantile):\n", " lower_bound = norm.ppf(lower_quantile) # Lower bound of the range\n", " upper_bound = norm.ppf(upper_quantile) # Upper bound of the range\n", " \n", " area_weight = norm.cdf(upper_bound) - norm.cdf(lower_bound)\n", " \n", " return area_weight\n", "\n", "# Define the quantiles and ranges\n", "quantiles_ranges = {\n", " 'q0.05': (0, 0.15),\n", " 'q0.25': (0.15, 0.375),\n", " 'q0.5': (0.375, 0.625),\n", " 'q0.75': (0.625, 0.85),\n", " 'q0.95': (0.85, 1)\n", "}\n", "\n", "# Calculate area weights for each range\n", "area_weights = {}\n", "for quantile, (lower, upper) in quantiles_ranges.items():\n", " area_weights[quantile] = calculate_area_weight(lower, upper)\n", "\n", "# Output the results\n", "for quantile, weight in area_weights.items():\n", " print(f\"Area weight for {quantile}: {weight:.4f}\")\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "bb737bd4-bfb5-4ab9-8045-ab2f447b973a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1.0" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "0.25+0.225+0.225+0.15+0.15\n" ] }, { "cell_type": "code", "execution_count": null, "id": "e42fbcaa-abd9-4733-9b0b-9304affd8277", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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", "version": "3.10.12" } }, "nbformat": 4, "nbformat_minor": 5 }