|
28 | 28 | "name": "stderr", |
29 | 29 | "output_type": "stream", |
30 | 30 | "text": [ |
31 | | - "Compiling numba functions: 100%|███████████████████████████████████████████████████████| 11/11 [00:22<00:00, 2.01s/it]" |
| 31 | + "Compiling numba functions: 100%|███████████████████████████████████████████████████████| 11/11 [00:01<00:00, 7.62it/s]" |
32 | 32 | ] |
33 | 33 | }, |
34 | 34 | { |
|
179 | 179 | "execution_count": null, |
180 | 180 | "id": "258f4b73", |
181 | 181 | "metadata": {}, |
| 182 | + "outputs": [], |
| 183 | + "source": [ |
| 184 | + "difference = unpaired.mean_diff.mini_meta.difference\n", |
| 185 | + "\n", |
| 186 | + "np_means = np.array([np.mean(rep1_yes)-np.mean(rep1_no), \n", |
| 187 | + " np.mean(rep2_yes)-np.mean(rep2_no)])\n", |
| 188 | + "\n", |
| 189 | + "np_var = np_bootstrap_distribution_variances\n", |
| 190 | + "\n", |
| 191 | + "np_difference = effsize.weighted_delta(np_means, np_var)\n", |
| 192 | + "\n", |
| 193 | + "weight = np.true_divide(1, np_var)\n", |
| 194 | + "np_difference_calc = np.sum(np_means*weight)/np.sum(weight)\n", |
| 195 | + "\n", |
| 196 | + "assert difference == pytest.approx(np_difference) == pytest.approx(np_difference_calc)" |
| 197 | + ] |
| 198 | + }, |
| 199 | + { |
| 200 | + "cell_type": "code", |
| 201 | + "execution_count": null, |
| 202 | + "id": "4b9e81da-01f9-4880-acde-0dd9dd6caf12", |
| 203 | + "metadata": {}, |
182 | 204 | "outputs": [ |
183 | 205 | { |
184 | 206 | "data": { |
185 | 207 | "text/plain": [ |
186 | | - "-5.819190882223082" |
| 208 | + "array([-1.32919358, 1.17274469, 0.51495794, ..., 0.20620551,\n", |
| 209 | + " -2.86746452, 2.19964192])" |
187 | 210 | ] |
188 | 211 | }, |
189 | 212 | "execution_count": null, |
|
192 | 215 | } |
193 | 216 | ], |
194 | 217 | "source": [ |
195 | | - "difference = unpaired.mean_diff.mini_meta.difference\n", |
196 | | - "\n", |
197 | | - "np_means = np.array([np.mean(rep1_yes)-np.mean(rep1_no), \n", |
198 | | - " np.mean(rep2_yes)-np.mean(rep2_no)])\n", |
199 | | - "\n", |
200 | | - "np_var = np_bootstrap_distribution_variances\n", |
201 | | - "\n", |
202 | | - "np_difference = effsize.weighted_delta(np_means, np_var)\n", |
203 | | - "\n", |
204 | | - "assert difference == pytest.approx(np_difference)\n", |
205 | | - "weight = np.true_divide(1, np_var)\n", |
206 | | - "np.sum(np_means*weight)/np.sum(weight)" |
| 218 | + "mini_meta_delta.permutations_weighted_delta" |
207 | 219 | ] |
208 | 220 | }, |
209 | 221 | { |
|
217 | 229 | { |
218 | 230 | "cell_type": "code", |
219 | 231 | "execution_count": null, |
220 | | - "id": "45056c5f", |
| 232 | + "id": "d674181c-82c1-4116-804a-69e9def7d5c8", |
221 | 233 | "metadata": {}, |
222 | 234 | "outputs": [ |
223 | 235 | { |
224 | 236 | "data": { |
225 | 237 | "text/plain": [ |
226 | | - "0.0112" |
| 238 | + "0.0094" |
227 | 239 | ] |
228 | 240 | }, |
229 | 241 | "execution_count": null, |
|
247 | 259 | "permutations_1_var = perm_test_1.permutations_var\n", |
248 | 260 | "permutations_2_var = perm_test_2.permutations_var\n", |
249 | 261 | "\n", |
| 262 | + "perm_test_1\n", |
| 263 | + "\n", |
250 | 264 | "weight_1 = np.true_divide(1,permutations_1_var)\n", |
251 | 265 | "weight_2 = np.true_divide(1,permutations_2_var)\n", |
252 | 266 | "\n", |
253 | 267 | "weighted_deltas = (weight_1*permutations_1 + weight_2*permutations_2)/(weight_1+weight_2)\n", |
254 | 268 | "assert permutations_delta == pytest.approx(weighted_deltas)\n", |
255 | 269 | "\n", |
256 | 270 | "\n", |
257 | | - "np_means = [np.mean(rep1_yes)-np.mean(rep1_no), \n", |
258 | | - " np.mean(rep2_yes)-np.mean(rep2_no)]\n", |
259 | | - "np_var = [np.var(rep1_yes, ddof=1)/N+np.var(rep1_no, ddof=1)/N,\n", |
260 | | - " np.var(rep2_yes, ddof=1)/N+np.var(rep2_no, ddof=1)/N]\n", |
261 | | - "np_weight= np.true_divide(1, np_var)\n", |
| 271 | + "# np_means = [np.mean(rep1_yes)-np.mean(rep1_no), \n", |
| 272 | + "# np.mean(rep2_yes)-np.mean(rep2_no)]\n", |
| 273 | + "# np_var = [np.var(rep1_yes, ddof=1)/(N-1)+np.var(rep1_no, ddof=1)/(N-1),\n", |
| 274 | + "# np.var(rep2_yes, ddof=1)/(N-1)+np.var(rep2_no, ddof=1)/(N-1)]\n", |
262 | 275 | "\n", |
263 | | - "np_difference = np.sum(np_means*np_weight)/np.sum(np_weight)\n", |
| 276 | + "# np_weight= np.true_divide(1, np_var)\n", |
264 | 277 | "\n", |
265 | | - "np_pvalues = len(list(filter(lambda x: np.abs(x)>np.abs(np_difference), \n", |
266 | | - " weighted_deltas)))/len(weighted_deltas)\n", |
| 278 | + "# np_difference = np.sum(np_means*np_weight)/np.sum(np_weight)\n", |
| 279 | + "\n", |
| 280 | + "# np_pvalues = len(list(filter(lambda x: np.abs(x)>np.abs(np_difference), \n", |
| 281 | + "# weighted_deltas)))/len(weighted_deltas)\n", |
267 | 282 | "\n", |
268 | | - "pvalue\n", |
269 | 283 | "# assert pvalue == pytest.approx(np_pvalues)" |
270 | 284 | ] |
271 | 285 | }, |
272 | 286 | { |
273 | 287 | "cell_type": "code", |
274 | 288 | "execution_count": null, |
275 | | - "id": "01aef910-d540-4be5-9cf3-814f9aa36cd7", |
| 289 | + "id": "db42467a-0e0c-463e-be4a-a0a31f22db60", |
| 290 | + "metadata": {}, |
| 291 | + "outputs": [], |
| 292 | + "source": [ |
| 293 | + "np.abs(np_difference)" |
| 294 | + ] |
| 295 | + }, |
| 296 | + { |
| 297 | + "cell_type": "code", |
| 298 | + "execution_count": null, |
| 299 | + "id": "8c20cc0f-5b4e-4d24-9617-c346a3b5daa3", |
| 300 | + "metadata": {}, |
| 301 | + "outputs": [], |
| 302 | + "source": [ |
| 303 | + "pvalue" |
| 304 | + ] |
| 305 | + }, |
| 306 | + { |
| 307 | + "cell_type": "code", |
| 308 | + "execution_count": null, |
| 309 | + "id": "6e3bb0bd-b49f-48b0-98a9-fef495cb27a7", |
276 | 310 | "metadata": {}, |
277 | 311 | "outputs": [], |
278 | 312 | "source": [] |
|
0 commit comments