Skip to content

Instantly share code, notes, and snippets.

@alonsosilvaallende
Created May 25, 2022 11:33
Show Gist options
  • Save alonsosilvaallende/895232a1f78d988f5d752f9416c77545 to your computer and use it in GitHub Desktop.
Save alonsosilvaallende/895232a1f78d988f5d752f9416c77545 to your computer and use it in GitHub Desktop.
Untitled Folder/Untitled1.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-05-25T11:34:37.064167Z",
"end_time": "2022-05-25T11:34:38.437882Z"
},
"trusted": true
},
"cell_type": "code",
"source": "import numpy as np\nimport pandas as pd",
"execution_count": 1,
"outputs": []
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-05-25T11:34:38.440374Z",
"end_time": "2022-05-25T11:34:38.458690Z"
},
"trusted": true
},
"cell_type": "code",
"source": "t = 1\nalpha = 1\nt, alpha",
"execution_count": 2,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 2,
"data": {
"text/plain": "(1, 1)"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-05-25T11:34:38.462137Z",
"end_time": "2022-05-25T11:34:38.474538Z"
},
"trusted": true
},
"cell_type": "code",
"source": "zeta = np.linspace(1,2,5)\nzeta",
"execution_count": 3,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 3,
"data": {
"text/plain": "array([1. , 1.25, 1.5 , 1.75, 2. ])"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-05-25T11:34:38.483936Z",
"end_time": "2022-05-25T11:34:38.491698Z"
},
"trusted": true
},
"cell_type": "code",
"source": "lam = np.linspace(1,2,5)\nlam",
"execution_count": 4,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 4,
"data": {
"text/plain": "array([1. , 1.25, 1.5 , 1.75, 2. ])"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-05-25T11:34:38.497917Z",
"end_time": "2022-05-25T11:34:38.517347Z"
},
"trusted": true
},
"cell_type": "code",
"source": "y2 = [[np.exp(-t*((1+z)*alpha-l)) for z in zeta] for l in lam]\ny2",
"execution_count": 5,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 5,
"data": {
"text/plain": "[[0.36787944117144233,\n 0.2865047968601901,\n 0.22313016014842982,\n 0.17377394345044514,\n 0.1353352832366127],\n [0.4723665527410147,\n 0.36787944117144233,\n 0.2865047968601901,\n 0.22313016014842982,\n 0.17377394345044514],\n [0.6065306597126334,\n 0.4723665527410147,\n 0.36787944117144233,\n 0.2865047968601901,\n 0.22313016014842982],\n [0.7788007830714049,\n 0.6065306597126334,\n 0.4723665527410147,\n 0.36787944117144233,\n 0.2865047968601901],\n [1.0,\n 0.7788007830714049,\n 0.6065306597126334,\n 0.4723665527410147,\n 0.36787944117144233]]"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-05-25T11:34:38.524551Z",
"end_time": "2022-05-25T11:34:38.542956Z"
},
"trusted": true
},
"cell_type": "code",
"source": "y2 = pd.DataFrame()\ny2.index = zeta\nfor l in lam:\n y2[l] = [np.exp(-t*((1+z)*alpha-l)) for z in zeta]",
"execution_count": 6,
"outputs": []
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-05-25T11:34:38.554079Z",
"end_time": "2022-05-25T11:34:38.588683Z"
},
"trusted": true
},
"cell_type": "code",
"source": "y2",
"execution_count": 7,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 7,
"data": {
"text/plain": " 1.00 1.25 1.50 1.75 2.00\n1.00 0.367879 0.472367 0.606531 0.778801 1.000000\n1.25 0.286505 0.367879 0.472367 0.606531 0.778801\n1.50 0.223130 0.286505 0.367879 0.472367 0.606531\n1.75 0.173774 0.223130 0.286505 0.367879 0.472367\n2.00 0.135335 0.173774 0.223130 0.286505 0.367879",
"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>1.00</th>\n <th>1.25</th>\n <th>1.50</th>\n <th>1.75</th>\n <th>2.00</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>1.00</th>\n <td>0.367879</td>\n <td>0.472367</td>\n <td>0.606531</td>\n <td>0.778801</td>\n <td>1.000000</td>\n </tr>\n <tr>\n <th>1.25</th>\n <td>0.286505</td>\n <td>0.367879</td>\n <td>0.472367</td>\n <td>0.606531</td>\n <td>0.778801</td>\n </tr>\n <tr>\n <th>1.50</th>\n <td>0.223130</td>\n <td>0.286505</td>\n <td>0.367879</td>\n <td>0.472367</td>\n <td>0.606531</td>\n </tr>\n <tr>\n <th>1.75</th>\n <td>0.173774</td>\n <td>0.223130</td>\n <td>0.286505</td>\n <td>0.367879</td>\n <td>0.472367</td>\n </tr>\n <tr>\n <th>2.00</th>\n <td>0.135335</td>\n <td>0.173774</td>\n <td>0.223130</td>\n <td>0.286505</td>\n <td>0.367879</td>\n </tr>\n </tbody>\n</table>\n</div>"
},
"metadata": {}
}
]
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3 (ipykernel)",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.9.7",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"gist": {
"id": "",
"data": {
"description": "Untitled Folder/Untitled1.ipynb",
"public": true
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment