misc python code
This commit is contained in:
127
code/misc/python/scripts/studenttprocess.ipynb
Normal file
127
code/misc/python/scripts/studenttprocess.ipynb
Normal file
@@ -0,0 +1,127 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"import scipy as sc\n",
|
||||
"import pandas as pd\n",
|
||||
"from matplotlib import pyplot as plt\n",
|
||||
"from scipy import stats \n",
|
||||
"from IPython.core.interactiveshell import InteractiveShell\n",
|
||||
"InteractiveShell.ast_node_interactivity = \"all\"\n",
|
||||
"\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 52,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"KstestResult(statistic=0.0019255354784954437, pvalue=0.8515501507924718, statistic_location=-0.003026398265409117, statistic_sign=1)"
|
||||
]
|
||||
},
|
||||
"execution_count": 52,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"KstestResult(statistic=0.0019317484822836684, pvalue=0.8488394389115358, statistic_location=-0.003041920835342991, statistic_sign=1)"
|
||||
]
|
||||
},
|
||||
"execution_count": 52,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"rng = np.random.default_rng()#(seed=1234)\n",
|
||||
"dof=100\n",
|
||||
"size=(100000)\n",
|
||||
"dt=15/365\n",
|
||||
"sqrtdt=np.sqrt(dt)\n",
|
||||
"sfactor=np.sqrt((dof-2)/dof)\n",
|
||||
"\n",
|
||||
"#np.sqrt(1/np.random.gamma(dof/2,dof/2,nsims))\n",
|
||||
"\n",
|
||||
"N=rng.normal(0,sqrtdt,size)\n",
|
||||
"W=1/np.sqrt(rng.chisquare(dof,size)/dof)\n",
|
||||
"T=sfactor*N*W\n",
|
||||
"\n",
|
||||
"stats.kstest(N,\"norm\",args=(0,sqrtdt))\n",
|
||||
"assert stats.kstest(N,\"norm\",args=(0,sqrtdt)).pvalue>0.05 #accept null of normality\n",
|
||||
"\n",
|
||||
"stats.kstest(T,\"t\",args=(dof,0,sfactor*sqrtdt))\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"#stats.kstest(T,T1)\n",
|
||||
"\n",
|
||||
"#pd.Series(T).describe()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 50,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"array([0.04109589, 0.08219178, 0.12328767, 0.16438356, 0.20547945,\n",
|
||||
" 0.24657534, 0.28767123, 0.32876712, 0.36986301, 0.4109589 ,\n",
|
||||
" 0.45205479, 0.49315068, 0.53424658, 0.57534247, 0.61643836,\n",
|
||||
" 0.65753425, 0.69863014, 0.73972603, 0.78082192, 0.82191781,\n",
|
||||
" 0.8630137 , 0.90410959, 0.94520548, 0.98630137])"
|
||||
]
|
||||
},
|
||||
"execution_count": 50,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"days=np.arange(15,365,15)\n",
|
||||
"timegrid=days/365\n",
|
||||
"\n",
|
||||
"timegrid"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Main",
|
||||
"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.11.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
Reference in New Issue
Block a user