|
33 | 33 | "import numpy as np\n",
|
34 | 34 | "\n",
|
35 | 35 | "def criterion(x):\n",
|
36 |
| - " first = (x[\"a\"] - np.pi) ** 4 \n", |
37 |
| - " second = np.linalg.norm(x[\"b\"] - np.arange(3))\n", |
38 |
| - " third = np.linalg.norm(x[\"c\"] - np.eye(2))\n", |
| 36 | + " first = (x[\"a\"] - np.pi) ** 2\n", |
| 37 | + " second = np.sum((x[\"b\"] - np.arange(3)) ** 2)\n", |
| 38 | + " third = np.sum((x[\"c\"] - np.eye(2)) ** 2)\n", |
39 | 39 | " return first + second + third\n",
|
40 | 40 | " \n",
|
41 | 41 | " \n",
|
|
55 | 55 | {
|
56 | 56 | "data": {
|
57 | 57 | "text/plain": [
|
58 |
| - "{'a': 2.743115791004308,\n", |
59 |
| - " 'b': array([7.20526405e-06, 1.00000542e+00, 1.99999951e+00]),\n", |
60 |
| - " 'c': array([[ 1.00000752e+00, -1.83976834e-06],\n", |
61 |
| - " [ 5.75654246e-06, 1.00000339e+00]])}" |
| 58 | + "{'a': 3.141592653589793,\n", |
| 59 | + " 'b': array([1.55630437e-16, 1.00000000e+00, 2.00000000e+00]),\n", |
| 60 | + " 'c': array([[ 1.00000000e+00, -4.50891722e-18],\n", |
| 61 | + " [-4.51479888e-18, 1.00000000e+00]])}" |
62 | 62 | ]
|
63 | 63 | },
|
64 | 64 | "execution_count": 2,
|
|
98 | 98 | "data": {
|
99 | 99 | "text/plain": [
|
100 | 100 | "{'a': 2.0,\n",
|
101 |
| - " 'b': array([0.5 , 1.11950355, 1.82926046]),\n", |
102 |
| - " 'c': array([[1.00000104e+00, 1.57485251e-06],\n", |
103 |
| - " [5.38584210e-06, 1.00000320e+00]])}" |
| 101 | + " 'b': array([0.5, 1. , 2. ]),\n", |
| 102 | + " 'c': array([[1., 0.],\n", |
| 103 | + " [0., 1.]])}" |
104 | 104 | ]
|
105 | 105 | },
|
106 | 106 | "execution_count": 3,
|
|
142 | 142 | "data": {
|
143 | 143 | "text/plain": [
|
144 | 144 | "{'a': 1.0,\n",
|
145 |
| - " 'b': array([1.30231301e-06, 1.00000089e+00, 2.00000549e+00]),\n", |
146 |
| - " 'c': array([[1.02551721, 1. ],\n", |
147 |
| - " [0.05069564, 0.9944641 ]])}" |
| 145 | + " 'b': array([0., 1., 2.]),\n", |
| 146 | + " 'c': array([[1., 1.],\n", |
| 147 | + " [0., 1.]])}" |
148 | 148 | ]
|
149 | 149 | },
|
150 | 150 | "execution_count": 4,
|
|
188 | 188 | "name": "stderr",
|
189 | 189 | "output_type": "stream",
|
190 | 190 | "text": [
|
191 |
| - "/Users/Tim_Mensinger/miniconda3/envs/scipy-estimagic/lib/python3.9/site-packages/pandas/core/frame.py:6254: FutureWarning: In a future version, the Index constructor will not infer numeric dtypes when passed object-dtype sequences (matching Series behavior)\n", |
| 191 | + "/Users/Tim_Mensinger/miniconda3/envs/scipy-test/lib/python3.9/site-packages/pandas/core/frame.py:6254: FutureWarning: In a future version, the Index constructor will not infer numeric dtypes when passed object-dtype sequences (matching Series behavior)\n", |
192 | 192 | " diff = Index(subset).difference(self.columns)\n"
|
193 | 193 | ]
|
194 | 194 | },
|
195 | 195 | {
|
196 | 196 | "data": {
|
197 | 197 | "text/plain": [
|
198 |
| - "{'a': 2.855857369098579,\n", |
199 |
| - " 'b': array([-1.03938095e-06, 1.00000208e+00, 1.99999922e+00]),\n", |
200 |
| - " 'c': array([[ 0.32051835, 0.03349061],\n", |
201 |
| - " [-0.00143225, 0.64742329]])}" |
| 198 | + "{'a': 3.1415928282824384,\n", |
| 199 | + " 'b': array([-7.47836576e-09, 9.99999785e-01, 2.00000000e+00]),\n", |
| 200 | + " 'c': array([[ 0.75000093, -0.24999997],\n", |
| 201 | + " [-0.25000073, 0.74999977]])}" |
202 | 202 | ]
|
203 | 203 | },
|
204 | 204 | "execution_count": 5,
|
|
0 commit comments