Skip to content

Commit 44999d8

Browse files
committed
chore: resolve lint errors
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: passed - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 0223c17 commit 44999d8

File tree

1 file changed

+24
-15
lines changed
  • lib/node_modules/@stdlib/stats/strided/dcovmatmtk/test/fixtures

1 file changed

+24
-15
lines changed

lib/node_modules/@stdlib/stats/strided/dcovmatmtk/test/fixtures/script.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,46 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18+
"""
19+
This script is meant to be copy-pasted into an IPython REPL session.
20+
21+
Upon execution, enter `X` to print the contents of the generated array of random
22+
values.
23+
24+
To generate an array containing the biased covariance, set the `bias` kwarg to
25+
`True`.
26+
"""
27+
28+
import numpy as np
29+
1830
# Define the list of known means:
19-
mean = [ 1.0, 1.0 ];
31+
mean = [1.0, 1.0]
2032

2133
# Create a 2x3 matrix of mean values:
22-
broadcasted_mean = np.broadcast_to(mean, (3,2)).T;
34+
broadcasted_mean = np.broadcast_to(mean, (3, 2)).T
2335

2436
# Define the matrix of standard deviations:
2537
sigma = [
26-
[ 1.0, 0.7 ],
27-
[ 0.7, 1.0 ]
28-
];
38+
[1.0, 0.7],
39+
[0.7, 1.0]
40+
]
2941

3042
# Generate a random sample of normally distributed numbers:
31-
X = np.random.default_rng().multivariate_normal(mean, sigma, 3).T;
43+
X = np.random.default_rng().multivariate_normal(mean, sigma, 3).T
3244

3345
# Center the generated values:
3446
for n in range(X.shape[0]):
3547
X[n] = X[n] - X[n].mean()
3648

3749
# Transform the generated values via Cholesky decomposition (see https://stats.stackexchange.com/questions/120179/generating-data-with-a-given-sample-covariance-matrix and https://www.r-bloggers.com/2011/10/simulating-data-following-a-given-covariance-structure/)...
38-
L_inv = np.linalg.inv(np.linalg.cholesky(np.cov(X, bias = False)));
39-
X = np.dot(L_inv, X);
50+
L_inv = np.linalg.inv(np.linalg.cholesky(np.cov(X, bias=False)))
51+
X = np.dot(L_inv, X)
4052

41-
L = np.linalg.cholesky(sigma);
42-
X = np.dot(L, X);
53+
L = np.linalg.cholesky(sigma)
54+
X = np.dot(L, X)
4355

4456
# Un-center the transformed values:
45-
X += broadcasted_mean;
46-
47-
# Display the generated values:
48-
X
57+
X += broadcasted_mean
4958

5059
# Confirm that the generated values have the expected covariance matrix:
51-
np.cov(X, bias = False)
60+
np.cov(X, bias=False)

0 commit comments

Comments
 (0)