{
 "metadata":{},
 "nbformat":4,
 "nbformat_minor":4,
 "cells":[
  {
   "cell_type":"markdown",
   "metadata":{
    "editable":true
   },
   "source":[
    "<!-- jupyter-book 04_05_testdoc.ipynb -->\n",
    "# Project: Explore Distributions of Random Circles\n",
    "\n",
    "<div id=\"proj:circle1\"></div>\n",
    "file=circles\n",
    "kw=ipynb\n",
    "\n",
    "The formula for a circle is given by"
   ]
  },
  {
   "cell_type":"markdown",
   "metadata":{
    "editable":true
   },
   "source":[
    "<!-- Equation labels as ordinary links -->\n",
    "<div id=\"circle:x\"></div>\n",
    "\n",
    "$$\n",
    "\\begin{equation}\n",
    "x = x_0 + R\\cos 2\\pi t,\n",
    "\\label{circle:x} \\tag{11}\n",
    "\\end{equation}\n",
    "$$"
   ]
  },
  {
   "cell_type":"markdown",
   "metadata":{
    "editable":true
   },
   "source":[
    "<!-- Equation labels as ordinary links -->\n",
    "<div id=\"circle:y\"></div>\n",
    "\n",
    "$$\n",
    "\\begin{equation}  \n",
    "y = y_0 + R\\sin 2\\pi t,\n",
    "\\label{circle:y} \\tag{12}\n",
    "\\end{equation}\n",
    "$$"
   ]
  },
  {
   "cell_type":"markdown",
   "metadata":{
    "editable":true
   },
   "source":[
    "where $R$ is the radius of the circle, $(x_0,y_0)$ is the\n",
    "center point, and $t$ is a parameter in the unit interval $[0,1]$.\n",
    "For any $t$, $(x,y)$ computed from ([11](04_05_testdoc.html#circle:x))-([12](04_05_testdoc.html#circle:y))\n",
    "is a point on the circle.\n",
    "The formula can be used to generate `n` points on a circle:"
   ]
  },
  {
   "cell_type":"code",
   "execution_count":10,
   "metadata":{
    "collapsed":false,
    "editable":true
   },
   "outputs":[],
   "source":[
    "import numpy as np\n",
    "\n",
    "def circle(R, x0, y0, n=501):\n",
    "    t = np.linspace(0, 1, n)\n",
    "    x = x0 + R*np.cos(2*np.pi*t)\n",
    "    y = y0 + R*np.sin(2*np.pi*t)\n",
    "    return x, y\n",
    "\n",
    "x, y = circle(2.0, 0, 0)"
   ]
  },
  {
   "cell_type":"markdown",
   "metadata":{
    "editable":true
   },
   "source":[
    "<!-- Often in an exercise we have some comments about the solution -->\n",
    "<!-- which we normally want to keep where they are. -->\n",
    "\n",
    "The goal of this project is to draw $N$ circles with random\n",
    "center and radius. Plot each circle using the `circle` function\n",
    "above.\n",
    "\n",
    "!bsubex\n",
    "Let $R$ be normally distributed and $(x_0,y_0)$ uniformly distributed.\n",
    "\n",
    "!bans\n",
    "Here goes the short answer to part a).\n",
    "!eans\n",
    "\n",
    "!bsol\n",
    "Here goes a full solution to part a).\n",
    "!esol\n",
    "\n",
    "**Hint.**\n",
    "\n",
    "Use the `numpy.random` module to draw the\n",
    "$x_0$, $y_0$, and $R$ quantities.\n",
    "\n",
    "\n",
    "\n",
    "!esubex\n",
    "\n",
    "!bsubex\n",
    "Let $R$ be uniformly distributed and $(x_0,y_0)$ normally distributed.\n",
    "\n",
    "file=norm  # test local filename for subexercise\n",
    "!esubex\n",
    "\n",
    "!bsubex\n",
    "Let $R$ and $(x_0,y_0)$ be normally distributed.\n",
    "!esubex\n",
    "\n",
    "**Remarks.**\n",
    "\n",
    "At the very end of the exercise it may be appropriate to summarize\n",
    "and give some perspectives."
   ]
  }
 ]
}