|
1687 | 1687 | "metadata": {}, |
1688 | 1688 | "outputs": [], |
1689 | 1689 | "source": [ |
| 1690 | + "import numpy as np\n", |
| 1691 | + "\n", |
1690 | 1692 | "xdata = [ -10.0, -9.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]\n", |
1691 | | - "ydata = [1.2, 4.2, 6.7, 8.3, 10.6, 11.7, 13.5, 14.5, 15.7, 16.1, 16.6, 16.0, 15.4, 14.4, 14.2, 12.7, 10.3, 8.6, 6.1, 3.9, 2.1]" |
| 1693 | + "ydata = [1.2, 4.2, 6.7, 8.3, 10.6, 11.7, 13.5, 14.5, 15.7, 16.1, 16.6, 16.0, 15.4, 14.4, 14.2, 12.7, 10.3, 8.6, 6.1, 3.9, 2.1]\n", |
| 1694 | + "xdata = np.array(xdata)\n", |
| 1695 | + "ydata = np.array(ydata)" |
1692 | 1696 | ] |
1693 | 1697 | }, |
1694 | 1698 | { |
|
1726 | 1730 | "def solution_gaussian(): # do not change the function signature\n", |
1727 | 1731 | " # 2. TODO: define function to fit: the Gaussian.\n", |
1728 | 1732 | "\n", |
1729 | | - " # 3. TODO: call the curve_fit function here and return the parameters and covariance matrix AS A TUPLE\n", |
1730 | | - " pass" |
| 1733 | + " def gaussian_func(x, a, b):\n", |
| 1734 | + " \"\"\"\n", |
| 1735 | + " Use this function signature, and these parameters A and B.\n", |
| 1736 | + " a: coefficient of the Gaussian\n", |
| 1737 | + " b: coefficient of the x^2 term\n", |
| 1738 | + "\n", |
| 1739 | + " Will probably return an error if you change this.\n", |
| 1740 | + "\n", |
| 1741 | + " Returns: the Gaussian function using the parameters a and b\n", |
| 1742 | + " \"\"\"\n", |
| 1743 | + " \n", |
| 1744 | + " # 3. TODO: call the curve_fit function here and return the parameters and covariance matrix AS A TUPLE" |
1731 | 1745 | ] |
1732 | 1746 | }, |
1733 | 1747 | { |
|
0 commit comments