Download tasks/bicycle_studio/solution/reference/das_dennis.py from Tokenwave-AI/REE: direct link, hf CLI and curl.
- Browser
- Download file 735 Bytes
-
https://huggingface.co/datasets/Tokenwave-AI/REE/resolve/main/tasks/bicycle_studio/solution/reference/das_dennis.py
- Command line
-
hf download hf://datasets/Tokenwave-AI/REE/tasks/bicycle_studio/solution/reference/das_dennis.py
-
curl -L -o das_dennis.py https://huggingface.co/datasets/Tokenwave-AI/REE/resolve/main/tasks/bicycle_studio/solution/reference/das_dennis.py
735 Bytes
| import numpy as np | |
| def das_dennis(n_partitions, n_dim): | |
| if n_partitions == 0: | |
| return np.full((1, n_dim), 1 / n_dim) | |
| else: | |
| ref_dirs = [] | |
| ref_dir = np.full(n_dim, np.nan) | |
| das_dennis_recursion(ref_dirs, ref_dir, n_partitions, n_partitions, 0) | |
| return np.concatenate(ref_dirs, axis=0) | |
| def das_dennis_recursion(ref_dirs, ref_dir, n_partitions, beta, depth): | |
| if depth == len(ref_dir) - 1: | |
| ref_dir[depth] = beta / (1.0 * n_partitions) | |
| ref_dirs.append(ref_dir[None, :]) | |
| else: | |
| for i in range(beta + 1): | |
| ref_dir[depth] = 1.0 * i / (1.0 * n_partitions) | |
| das_dennis_recursion(ref_dirs, np.copy(ref_dir), n_partitions, beta - i, depth + 1) | |