solutions update from 18a5097

This commit is contained in:
rougier
2025-08-26 09:06:26 +00:00
committed by github-actions[bot]
parent 18a5097890
commit 521b1c0c75
4 changed files with 215 additions and 213 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -993,7 +993,8 @@ print(sliding_window_view(Z, window_shape=4))
Z = np.random.uniform(0,1,(10,10)) Z = np.random.uniform(0,1,(10,10))
U, S, V = np.linalg.svd(Z) # Singular Value Decomposition U, S, V = np.linalg.svd(Z) # Singular Value Decomposition
rank = np.sum(S > 1e-10) threshold = len(S) * S.max() * np.finfo(S.dtype).eps
rank = np.sum(S > threshold)
print(rank) print(rank)
# alternative solution: # alternative solution:

View File

@@ -993,7 +993,8 @@ print(sliding_window_view(Z, window_shape=4))
Z = np.random.uniform(0,1,(10,10)) Z = np.random.uniform(0,1,(10,10))
U, S, V = np.linalg.svd(Z) # Singular Value Decomposition U, S, V = np.linalg.svd(Z) # Singular Value Decomposition
rank = np.sum(S > 1e-10) threshold = len(S) * S.max() * np.finfo(S.dtype).eps
rank = np.sum(S > threshold)
print(rank) print(rank)
# alternative solution: # alternative solution:

View File

@@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "738eba3f", "id": "c2a7dc72",
"metadata": {}, "metadata": {},
"source": [ "source": [
"# 100 numpy exercises\n", "# 100 numpy exercises\n",
@@ -18,7 +18,7 @@
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "f65f901e", "id": "0f9c3a25",
"metadata": {}, "metadata": {},
"source": [ "source": [
"File automatically generated. See the documentation to update questions/answers/hints programmatically." "File automatically generated. See the documentation to update questions/answers/hints programmatically."
@@ -26,17 +26,17 @@
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "15045647", "id": "7334326e",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Run the `initialize.py` module, then call a random question with `pick()` an hint towards its solution with\n", "Run the `initialise.py` module, then call a random question with `pick()` an hint towards its solution with\n",
"`hint(n)` and the answer with `answer(n)`, where n is the number of the picked question." "`hint(n)` and the answer with `answer(n)`, where n is the number of the picked question."
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "0d23aa5b", "id": "abd0d1b2",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@@ -46,7 +46,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "4a6a613b", "id": "ecfa16ec",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [