{ "cells": [ { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## P3800 Assignment 3" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "import sympy as sp\n", "import numpy as np\n", "import pandas as pd\n", "from ipywidgets import interactive, fixed\n", "\n", "import os\n", "import glob\n", "import scipy.special as sf" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Check out binomial coefficients from scipy\n", "\n", "\"5 choose 2\" = 5!/3!/2!=5*2=10" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sf.binom(5,2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Please include code used to generate data.\n", "E.g.\n", "\n", "```\n", "program A3Q1\n", "\n", "implicit none\n", "\n", "integer,parameter :: seed = 837245, p= 521, q=168, nsteps=20\n", "integer, parameter :: M=nsteps+p\n", "integer, dimension(M) :: randseq\n", "integer :: x\n", "integer :: i, j, n, indn,indp,indq, nsamples\n", "integer, dimension(-nsteps:nsteps) :: pos\n", "\n", " i=irand(seed)\n", "\n", " do i=1,p\n", " randseq(i)=irand()\n", " enddo \n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# df = pd.read_csv(xxx,sep='\\s+',names=xxx)\n", "\n", "# plt.plot(xxx,xxx,label='xxx',color=\"Red\")\n", "\n", "\n", "# # label axes\n", "# plt.xlabel('xxx')\n", "# plt.ylabel('xxx')\n", "\n", "\n", "\n", "\n", "# plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get a directory listing multiple ways." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!ls" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "os.listdir()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "filelist=glob.glob(\"./*\")\n", "print(filelist)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\n", "# # label axes\n", "# plt.xlabel('MC steps')\n", "# plt.ylabel('Absolute Error')\n", "\n", "\n", "# plt.legend()\n", "# plt.title(\"Error as a function of number of MC steps\")\n", "\n", "# plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.8.3" } }, "nbformat": 4, "nbformat_minor": 2 }