scientific-computing-system 1.0.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +365 -0
- package/LICENSE +0 -0
- package/README.md +146 -217
- package/SECURITY.md +32 -6
- package/bin/scs.js +12 -2
- package/index.js +115 -1
- package/package.json +45 -1
- package/.binder/postBuild +0 -9
- package/.binder/requirements.txt +0 -10
- package/.gitattributes +0 -35
- package/.github/CODEOWNERS +0 -4
- package/.github/FUNDING.yml +0 -3
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -50
- package/.github/ISSUE_TEMPLATE/config.yml +0 -8
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -28
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -29
- package/.github/dependabot.yml +0 -32
- package/.github/labeler.yml +0 -50
- package/.github/workflows/benchmarks.yml +0 -97
- package/.github/workflows/bot-reviewer.yml +0 -58
- package/.github/workflows/changelog.yml +0 -130
- package/.github/workflows/cli-package-smoke.yml +0 -45
- package/.github/workflows/codeql.yml +0 -55
- package/.github/workflows/npm-publish.yml +0 -33
- package/.github/workflows/p08-cancel-noncanonical-runs.yml +0 -41
- package/.github/workflows/pr-automation.yml +0 -78
- package/.github/workflows/public-external-validation-p08-v2-glm.yml +0 -161
- package/.github/workflows/public-external-validation-p08-v2-recovery-merge-gate.yml +0 -72
- package/.github/workflows/public-external-validation-p08-v2-recovery-merge.yml +0 -113
- package/.github/workflows/public-external-validation-p08-v2-run-recovery-anatomy-gate.yml +0 -57
- package/.github/workflows/public-external-validation-p08-v2-run-recovery-merge-gate.yml +0 -63
- package/.github/workflows/public-external-validation-p08-v2-run-recovery-merge.yml +0 -89
- package/.github/workflows/public-external-validation-p08-v2-run-recovery.yml +0 -182
- package/.github/workflows/public-external-validation-p08-v3-glm-gate.yml +0 -67
- package/.github/workflows/public-external-validation-p08-v4-recovery-glm-gate.yml +0 -78
- package/.github/workflows/public-external-validation-p08-v4-recovery-glm.yml +0 -248
- package/.github/workflows/public-external-validation-p08-v5-run-recovery-glm-gate.yml +0 -66
- package/.github/workflows/public-external-validation-p08-v5-run-recovery-glm.yml +0 -218
- package/.github/workflows/pypi-registry-smoke.yml +0 -116
- package/.github/workflows/release.yml +0 -359
- package/.github/workflows/tests.yml +0 -250
- package/.github/workflows/tmp-compassion-raw-acquire.yml +0 -63
- package/.github/workflows/wsl-science-runner-smoke.yml +0 -45
- package/.pre-commit-config.yaml +0 -48
- package/CITATION.cff +0 -29
- package/CODE_OF_CONDUCT.md +0 -25
- package/CONTRIBUTING.md +0 -275
- package/ROADMAP.md +0 -155
- package/assets/logo.svg +0 -38
- package/assets/social_preview.png +0 -0
- package/benchmarks/results.json +0 -43
- package/benchmarks/robust_runner.py +0 -118
- package/benchmarks/run_benchmarks.py +0 -394
- package/cliff.toml +0 -100
- package/dashboard/app.py +0 -224
- package/docs/ARCHITECTURE.md +0 -252
- package/docs/CASE_STUDY_HUBBLE.md +0 -78
- package/docs/CASE_STUDY_QUANTUM_ML.md +0 -79
- package/docs/api.md +0 -133
- package/docs/assets/icon.svg +0 -17
- package/docs/assets/logo.svg +0 -38
- package/docs/benchmarks.md +0 -62
- package/docs/cookbook.md +0 -930
- package/docs/getting-started.md +0 -185
- package/docs/index.md +0 -111
- package/docs/maintenance.md +0 -61
- package/docs/ml_reference.md +0 -92
- package/docs/research-workflows.md +0 -82
- package/docs/stylesheets/extra.css +0 -122
- package/docs/tour_of_numerical_methods.md +0 -330
- package/docs/tutorials/core_demo.md +0 -35
- package/docs/tutorials/data_analysis_demo.md +0 -43
- package/docs/tutorials/diffeq_demo.md +0 -48
- package/docs/tutorials/fft2_demo.md +0 -67
- package/docs/tutorials/graph_demo.md +0 -45
- package/docs/tutorials/hypothesis_demo.md +0 -44
- package/docs/tutorials/hypothesis_tests_demo.md +0 -170
- package/docs/tutorials/hypothesis_with_stats_demo.md +0 -80
- package/docs/tutorials/knowledge_demo.md +0 -114
- package/docs/tutorials/linalg_demo.md +0 -103
- package/docs/tutorials/math_utils_demo.md +0 -46
- package/docs/tutorials/ml_advanced_demo.md +0 -96
- package/docs/tutorials/ml_and_viz_demo.md +0 -93
- package/docs/tutorials/ml_demo.md +0 -70
- package/docs/tutorials/modeling_demo.md +0 -82
- package/docs/tutorials/montecarlo_demo.md +0 -42
- package/docs/tutorials/nlp_attention_demo.md +0 -107
- package/docs/tutorials/nlp_bpe_demo.md +0 -103
- package/docs/tutorials/nlp_mini_gpt_demo.md +0 -110
- package/docs/tutorials/nlp_viz.md +0 -76
- package/docs/tutorials/numerical_integration_demo.md +0 -65
- package/docs/tutorials/optimization_demo.md +0 -106
- package/docs/tutorials/pandas_io_demo.md +0 -160
- package/docs/tutorials/pca_demo.md +0 -87
- package/docs/tutorials/probability_demo.md +0 -48
- package/docs/tutorials/quantum_demo.md +0 -31
- package/docs/tutorials/quick_start.md +0 -44
- package/docs/tutorials/scientific_demo.md +0 -46
- package/docs/tutorials/signals_demo.md +0 -167
- package/docs/tutorials/stats_demo.md +0 -94
- package/docs/tutorials/stiff_ode_demo.md +0 -84
- package/docs/tutorials/time_series_demo.md +0 -145
- package/examples/core_demo.py +0 -40
- package/examples/data_analysis_demo.py +0 -60
- package/examples/diffeq_demo.py +0 -34
- package/examples/discovery_pipeline_demo.py +0 -57
- package/examples/ensemble_showcase.py +0 -81
- package/examples/fft2_demo.py +0 -32
- package/examples/graph_demo.py +0 -49
- package/examples/hypothesis_custom_generator.py +0 -121
- package/examples/hypothesis_demo.py +0 -48
- package/examples/hypothesis_tests_demo.py +0 -52
- package/examples/hypothesis_with_stats_demo.py +0 -43
- package/examples/interpolate_demo.py +0 -57
- package/examples/knowledge_demo.py +0 -100
- package/examples/linalg_demo.py +0 -61
- package/examples/math_utils_demo.py +0 -53
- package/examples/ml_and_viz_demo.py +0 -47
- package/examples/modeling_demo.py +0 -110
- package/examples/montecarlo_demo.py +0 -41
- package/examples/nlp_attention_demo.py +0 -168
- package/examples/nlp_bpe_demo.py +0 -79
- package/examples/nlp_mini_gpt_demo.py +0 -76
- package/examples/nlp_viz_demo.py +0 -98
- package/examples/numerical_integration_demo.py +0 -60
- package/examples/optimization_demo.py +0 -34
- package/examples/pca_demo.py +0 -124
- package/examples/pde_demo.py +0 -65
- package/examples/plot_demo.py +0 -84
- package/examples/plotting_notebook.ipynb +0 -87
- package/examples/probability_demo.py +0 -39
- package/examples/quantum_demo.py +0 -42
- package/examples/scientific_demo.py +0 -49
- package/examples/signals_demo.py +0 -86
- package/examples/stats_demo.py +0 -40
- package/examples/tour_of_numerical_methods.ipynb +0 -497
- package/mkdocs.yml +0 -159
- package/pyproject.toml +0 -288
- package/requirements-dev.lock +0 -427
- package/requirements-dev.txt +0 -39
- package/requirements.lock +0 -6
- package/requirements.txt +0 -13
- package/scripts/build_gif.py +0 -111
- package/scripts/build_video.py +0 -214
- package/scripts/cleanup_deployments.py +0 -173
- package/scripts/crop_readme_png.py +0 -40
- package/scripts/make_pi_dashboard.py +0 -316
- package/scripts/make_pi_gif.py +0 -138
- package/scripts/publish.py +0 -203
- package/scripts/render_promo.mjs +0 -93
- package/scripts/render_readme.py +0 -211
- package/scripts/render_readme_sections.py +0 -168
- package/scripts/verify_cli_install.py +0 -99
- package/scripts/verify_cookbook.py +0 -601
- package/scripts/verify_d1_numerics.py +0 -504
- package/scripts/verify_d2_edge_cases.py +0 -442
- package/scripts/verify_d4_hypothesis.py +0 -337
- package/scripts/verify_ml_reference.py +0 -160
- package/scripts/verify_pypi_release.py +0 -97
- package/scripts/verify_release_integrity.py +0 -194
- package/src/cds/__init__.py +0 -132
- package/src/cds/__main__.py +0 -8
- package/src/cds/_version.py +0 -11
- package/src/cds/bayes/__init__.py +0 -25
- package/src/cds/bayes/conjugate.py +0 -560
- package/src/cds/cli/__init__.py +0 -104
- package/src/cds/cli/__main__.py +0 -8
- package/src/cds/cli/_handlers.py +0 -323
- package/src/cds/cli/_parser.py +0 -155
- package/src/cds/cli/_style.py +0 -208
- package/src/cds/cli/_system_info.py +0 -71
- package/src/cds/core/__init__.py +0 -5
- package/src/cds/core/_numeric.py +0 -92
- package/src/cds/core/models.py +0 -166
- package/src/cds/data_analysis/__init__.py +0 -30
- package/src/cds/data_analysis/dataset.py +0 -122
- package/src/cds/data_analysis/loader.py +0 -75
- package/src/cds/data_analysis/pandas_io.py +0 -108
- package/src/cds/data_analysis/transform.py +0 -36
- package/src/cds/data_analysis/viz.py +0 -88
- package/src/cds/data_io/__init__.py +0 -27
- package/src/cds/data_io/streaming.py +0 -314
- package/src/cds/diffeq/__init__.py +0 -37
- package/src/cds/diffeq/_implicit.py +0 -349
- package/src/cds/diffeq/solvers.py +0 -312
- package/src/cds/diffeq/symplectic.py +0 -225
- package/src/cds/fractals/__init__.py +0 -34
- package/src/cds/fractals/sets.py +0 -356
- package/src/cds/genetics/__init__.py +0 -22
- package/src/cds/genetics/sequence.py +0 -199
- package/src/cds/graph/__init__.py +0 -31
- package/src/cds/graph/algorithms.py +0 -399
- package/src/cds/hypothesis/__init__.py +0 -51
- package/src/cds/hypothesis/evaluator.py +0 -311
- package/src/cds/hypothesis/generator.py +0 -275
- package/src/cds/hypothesis/mining.py +0 -314
- package/src/cds/infotheory/__init__.py +0 -25
- package/src/cds/infotheory/measures.py +0 -276
- package/src/cds/interpolate/__init__.py +0 -156
- package/src/cds/knowledge/__init__.py +0 -45
- package/src/cds/knowledge/graph.py +0 -489
- package/src/cds/knowledge/notes.py +0 -231
- package/src/cds/knowledge/retrieval.py +0 -339
- package/src/cds/math_utils/__init__.py +0 -46
- package/src/cds/math_utils/calculus.py +0 -40
- package/src/cds/math_utils/linalg.py +0 -496
- package/src/cds/math_utils/special.py +0 -167
- package/src/cds/math_utils/svd.py +0 -261
- package/src/cds/ml/__init__.py +0 -60
- package/src/cds/ml/boosting.py +0 -304
- package/src/cds/ml/clustering.py +0 -190
- package/src/cds/ml/decomposition.py +0 -172
- package/src/cds/ml/ensemble.py +0 -152
- package/src/cds/ml/linear_models.py +0 -225
- package/src/cds/ml/metrics.py +0 -227
- package/src/cds/ml/model_selection.py +0 -150
- package/src/cds/ml/naive_bayes.py +0 -179
- package/src/cds/ml/neighbors.py +0 -162
- package/src/cds/ml/neural.py +0 -204
- package/src/cds/ml/preprocessing.py +0 -131
- package/src/cds/ml/tree.py +0 -228
- package/src/cds/ml/voting.py +0 -175
- package/src/cds/modeling/__init__.py +0 -44
- package/src/cds/modeling/_base.py +0 -210
- package/src/cds/modeling/_nodes.py +0 -526
- package/src/cds/modeling/expression.py +0 -81
- package/src/cds/modeling/fitting.py +0 -477
- package/src/cds/modeling/model.py +0 -134
- package/src/cds/modeling/solver.py +0 -187
- package/src/cds/montecarlo/__init__.py +0 -24
- package/src/cds/montecarlo/markov.py +0 -112
- package/src/cds/montecarlo/methods.py +0 -294
- package/src/cds/nlp/__init__.py +0 -170
- package/src/cds/nlp/attention.py +0 -285
- package/src/cds/nlp/autograd/__init__.py +0 -70
- package/src/cds/nlp/autograd/_grad.py +0 -120
- package/src/cds/nlp/autograd/ops.py +0 -133
- package/src/cds/nlp/autograd/tensor.py +0 -298
- package/src/cds/nlp/bpe.py +0 -449
- package/src/cds/nlp/data.py +0 -70
- package/src/cds/nlp/embed.py +0 -190
- package/src/cds/nlp/layers.py +0 -259
- package/src/cds/nlp/model.py +0 -456
- package/src/cds/nlp/optim.py +0 -163
- package/src/cds/nlp/training.py +0 -167
- package/src/cds/nlp/viz.py +0 -254
- package/src/cds/numerical_integration/__init__.py +0 -31
- package/src/cds/numerical_integration/quadrature.py +0 -480
- package/src/cds/optimization/__init__.py +0 -26
- package/src/cds/optimization/_metaheuristics.py +0 -287
- package/src/cds/optimization/constrained.py +0 -212
- package/src/cds/optimization/minimize.py +0 -425
- package/src/cds/pde/__init__.py +0 -266
- package/src/cds/plot/__init__.py +0 -49
- package/src/cds/plot/_backend.py +0 -32
- package/src/cds/plot/charts.py +0 -462
- package/src/cds/probability/__init__.py +0 -65
- package/src/cds/probability/_advanced.py +0 -283
- package/src/cds/probability/distributions.py +0 -236
- package/src/cds/probability/extra_distributions.py +0 -199
- package/src/cds/provenance/__init__.py +0 -25
- package/src/cds/provenance/manifest.py +0 -355
- package/src/cds/py.typed +0 -0
- package/src/cds/quantum/__init__.py +0 -51
- package/src/cds/quantum/circuit.py +0 -122
- package/src/cds/quantum/multi_qubit.py +0 -310
- package/src/cds/quantum/simulator.py +0 -53
- package/src/cds/scientific/__init__.py +0 -34
- package/src/cds/scientific/constants.py +0 -35
- package/src/cds/scientific/formulas.py +0 -116
- package/src/cds/sensitivity.py +0 -204
- package/src/cds/signals/__init__.py +0 -59
- package/src/cds/signals/filters.py +0 -449
- package/src/cds/signals/processing.py +0 -224
- package/src/cds/signals/stft.py +0 -177
- package/src/cds/signals/wavelet.py +0 -146
- package/src/cds/stats/__init__.py +0 -99
- package/src/cds/stats/_distributions.py +0 -102
- package/src/cds/stats/bootstrap.py +0 -188
- package/src/cds/stats/descriptive.py +0 -172
- package/src/cds/stats/hypothesis_tests.py +0 -294
- package/src/cds/stats/nonparametric.py +0 -141
- package/src/cds/stats/power.py +0 -290
- package/src/cds/stats/regression.py +0 -51
- package/src/cds/stats/time_series.py +0 -420
- package/src/cds/tools/__init__.py +0 -29
- package/src/cds/tools/adapters.py +0 -218
- package/src/cds/tools/registry.py +0 -181
- package/src/cds/uncertainty/__init__.py +0 -17
- package/src/cds/uncertainty/propagation.py +0 -233
- package/src/cds/units/__init__.py +0 -45
- package/src/cds/units/core.py +0 -199
- package/src/cds/validation/__init__.py +0 -41
- package/src/cds/validation/adequacy.py +0 -157
- package/src/cds/validation/checks.py +0 -485
- package/src/cds/validation/report.py +0 -50
- package/src/cds/wavelets/__init__.py +0 -5
- package/src/cds/wavelets/haar.py +0 -219
- package/src/cds/workflow/__init__.py +0 -77
- package/src/cds/workflow/engine.py +0 -116
- package/src/cds/workflow/gates.py +0 -120
- package/src/cds/workflow/orchestrator.py +0 -431
- package/src/cds/workflow/selection.py +0 -454
- package/src/cds/workflow/tooling.py +0 -155
- package/src/cds/workflow/types.py +0 -107
- package/tests/__init__.py +0 -0
- package/tests/conftest.py +0 -109
- package/tests/test_advanced_fitting.py +0 -247
- package/tests/test_audit_completion_coverage.py +0 -183
- package/tests/test_audit_guard_coverage.py +0 -115
- package/tests/test_audit_hardening.py +0 -138
- package/tests/test_audit_hardening_coverage.py +0 -111
- package/tests/test_bayes_v2.py +0 -208
- package/tests/test_benchmarks.py +0 -111
- package/tests/test_bootstrap.py +0 -135
- package/tests/test_cli.py +0 -51
- package/tests/test_cli_color.py +0 -114
- package/tests/test_cli_extended.py +0 -239
- package/tests/test_cli_system_info.py +0 -36
- package/tests/test_constrained_opt.py +0 -174
- package/tests/test_core.py +0 -273
- package/tests/test_data_analysis.py +0 -146
- package/tests/test_data_analysis_lazy_bridge.py +0 -68
- package/tests/test_data_analysis_pandas_io.py +0 -119
- package/tests/test_data_io.py +0 -149
- package/tests/test_dataset.py +0 -91
- package/tests/test_diffeq.py +0 -186
- package/tests/test_diffeq_implicit.py +0 -173
- package/tests/test_domain_validation.py +0 -66
- package/tests/test_edge_misc_numerical.py +0 -666
- package/tests/test_edge_ml_quantum_linalg.py +0 -191
- package/tests/test_edge_nlp.py +0 -229
- package/tests/test_edge_quantum_evaluator_cli.py +0 -601
- package/tests/test_edge_stats_optimization_signals.py +0 -406
- package/tests/test_extra_distributions.py +0 -206
- package/tests/test_fft2.py +0 -67
- package/tests/test_fitting_bootstrap.py +0 -202
- package/tests/test_fractals.py +0 -387
- package/tests/test_genetics.py +0 -159
- package/tests/test_graph.py +0 -380
- package/tests/test_hardening_privacy_provenance.py +0 -306
- package/tests/test_hypothesis.py +0 -216
- package/tests/test_hypothesis_engine.py +0 -59
- package/tests/test_hypothesis_mining.py +0 -247
- package/tests/test_hypothesis_tests.py +0 -277
- package/tests/test_infotheory.py +0 -302
- package/tests/test_interpolate.py +0 -189
- package/tests/test_knowledge.py +0 -1149
- package/tests/test_layering.py +0 -112
- package/tests/test_linalg_extended.py +0 -179
- package/tests/test_linalg_qr_cholesky.py +0 -68
- package/tests/test_markov.py +0 -155
- package/tests/test_math_utils.py +0 -157
- package/tests/test_ml_boosting.py +0 -148
- package/tests/test_ml_clustering.py +0 -92
- package/tests/test_ml_ensemble.py +0 -103
- package/tests/test_ml_knn.py +0 -95
- package/tests/test_ml_linreg.py +0 -70
- package/tests/test_ml_logreg.py +0 -84
- package/tests/test_ml_metrics.py +0 -125
- package/tests/test_ml_model_selection.py +0 -108
- package/tests/test_ml_naive_bayes.py +0 -183
- package/tests/test_ml_pca.py +0 -98
- package/tests/test_ml_preprocessing.py +0 -104
- package/tests/test_ml_tree.py +0 -89
- package/tests/test_ml_viz.py +0 -58
- package/tests/test_ml_voting.py +0 -219
- package/tests/test_modeling.py +0 -726
- package/tests/test_modeling_fit_validation.py +0 -46
- package/tests/test_montecarlo.py +0 -245
- package/tests/test_multi_qubit.py +0 -466
- package/tests/test_nlp_attention.py +0 -335
- package/tests/test_nlp_autograd.py +0 -435
- package/tests/test_nlp_bpe.py +0 -463
- package/tests/test_nlp_embed.py +0 -240
- package/tests/test_nlp_layers.py +0 -276
- package/tests/test_nlp_model.py +0 -172
- package/tests/test_nlp_training.py +0 -262
- package/tests/test_nlp_viz.py +0 -188
- package/tests/test_numerical_integration.py +0 -374
- package/tests/test_numerical_invariants.py +0 -768
- package/tests/test_numerical_oracles.py +0 -241
- package/tests/test_optimization.py +0 -139
- package/tests/test_optimization_metaheuristics.py +0 -221
- package/tests/test_pde.py +0 -294
- package/tests/test_plot_charts.py +0 -247
- package/tests/test_plot_lazy.py +0 -48
- package/tests/test_power.py +0 -226
- package/tests/test_probability.py +0 -274
- package/tests/test_probability_advanced.py +0 -226
- package/tests/test_property_invariants.py +0 -277
- package/tests/test_provenance.py +0 -215
- package/tests/test_provenance_audit_hardening.py +0 -45
- package/tests/test_public_api.py +0 -75
- package/tests/test_quantum.py +0 -195
- package/tests/test_release_contract.py +0 -105
- package/tests/test_retrieval.py +0 -255
- package/tests/test_scientific.py +0 -185
- package/tests/test_selection_audit_hardening.py +0 -55
- package/tests/test_sensitivity.py +0 -59
- package/tests/test_sensitivity_global.py +0 -73
- package/tests/test_signals.py +0 -146
- package/tests/test_signals_filters.py +0 -460
- package/tests/test_special_invariants.py +0 -222
- package/tests/test_special_numerics.py +0 -44
- package/tests/test_statistical_audit.py +0 -75
- package/tests/test_stats.py +0 -206
- package/tests/test_stats_audit_coverage.py +0 -17
- package/tests/test_stats_nonparametric.py +0 -87
- package/tests/test_stats_time_series.py +0 -352
- package/tests/test_stft.py +0 -208
- package/tests/test_streaming_analytics.py +0 -128
- package/tests/test_svd.py +0 -170
- package/tests/test_symplectic.py +0 -200
- package/tests/test_tool_adapters.py +0 -197
- package/tests/test_tools_registry.py +0 -132
- package/tests/test_uncertainty.py +0 -171
- package/tests/test_units.py +0 -139
- package/tests/test_validation.py +0 -100
- package/tests/test_validation_adequacy.py +0 -129
- package/tests/test_validation_advanced.py +0 -110
- package/tests/test_wavelet.py +0 -170
- package/tests/test_wavelets_v2.py +0 -119
- package/tests/test_workflow.py +0 -173
- package/tests/test_workflow_gates.py +0 -144
- package/tests/test_workflow_orchestrator.py +0 -516
- package/tests/test_workflow_orchestrator_blocked_review.py +0 -95
- package/tests/test_workflow_selection.py +0 -312
- package/tests/test_workflow_selection_coverage.py +0 -114
- package/tests/test_workflow_tooling.py +0 -190
|
@@ -1,497 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"cells": [
|
|
3
|
-
{
|
|
4
|
-
"cell_type": "markdown",
|
|
5
|
-
"id": "c42536832",
|
|
6
|
-
"metadata": {},
|
|
7
|
-
"source": [
|
|
8
|
-
"# 🧭 A Tour of Numerical Methods with CDS\n",
|
|
9
|
-
"\n",
|
|
10
|
-
"An interactive walkthrough of classical numerical algorithms — implemented in **readable pure Python** with no NumPy/SciPy.\n",
|
|
11
|
-
"\n",
|
|
12
|
-
"> ▶️ **You're in Binder.** Every cell below is editable. Hit `Shift+Enter` to run a cell, then experiment with the parameters. This notebook mirrors the [Tour of Numerical Methods](https://furox-art.github.io/scientific-computing-system/tour_of_numerical_methods/) guide in the docs."
|
|
13
|
-
]
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"cell_type": "code",
|
|
17
|
-
"execution_count": null,
|
|
18
|
-
"id": "c42544640",
|
|
19
|
-
"metadata": {},
|
|
20
|
-
"outputs": [],
|
|
21
|
-
"source": [
|
|
22
|
-
"import cds\n",
|
|
23
|
-
"\n",
|
|
24
|
-
"print(\"Scientific Computing System v\" + cds.__version__)"
|
|
25
|
-
]
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"cell_type": "markdown",
|
|
29
|
-
"id": "c42544896",
|
|
30
|
-
"metadata": {},
|
|
31
|
-
"source": [
|
|
32
|
-
"## 1 · Numerical Integration — converging to the truth\n",
|
|
33
|
-
"\n",
|
|
34
|
-
"We integrate $\\int_0^1 e^x\\,dx = e - 1 \\approx 1.7182818...$ with a ladder of rules, each more accurate per function-evaluation than the last. Watch the error shrink as the rules get smarter."
|
|
35
|
-
]
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"cell_type": "code",
|
|
39
|
-
"execution_count": null,
|
|
40
|
-
"id": "c42545088",
|
|
41
|
-
"metadata": {},
|
|
42
|
-
"outputs": [],
|
|
43
|
-
"source": [
|
|
44
|
-
"import math\n",
|
|
45
|
-
"\n",
|
|
46
|
-
"from cds.numerical_integration import gaussian_quadrature, romberg, simpson, trapezoid\n",
|
|
47
|
-
"\n",
|
|
48
|
-
"f = math.exp\n",
|
|
49
|
-
"true_value = math.e - 1\n",
|
|
50
|
-
"\n",
|
|
51
|
-
"rules = {\n",
|
|
52
|
-
" \"Trapezoid (n=100)\": trapezoid(f, 0, 1, n=100),\n",
|
|
53
|
-
" \"Simpson 1/3 (n=100)\": simpson(f, 0, 1, n=100),\n",
|
|
54
|
-
" \"Romberg (max_iter=64)\": romberg(f, 0, 1, max_iter=64).value,\n",
|
|
55
|
-
" \"Gauss-Legendre (n=5)\": gaussian_quadrature(f, 0, 1, n=5),\n",
|
|
56
|
-
"}\n",
|
|
57
|
-
"\n",
|
|
58
|
-
"print(f\"{'Rule':<25} {'Estimate':>12} {'Error':>14}\")\n",
|
|
59
|
-
"print(\"-\" * 53)\n",
|
|
60
|
-
"for name, estimate in rules.items():\n",
|
|
61
|
-
" print(f\"{name:<25} {estimate:>12.8f} {estimate - true_value:>+14.2e}\")\n",
|
|
62
|
-
"print(f\"{'Exact (e-1)':<25} {true_value:>12.8f}\")"
|
|
63
|
-
]
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
"cell_type": "markdown",
|
|
67
|
-
"id": "c42545472",
|
|
68
|
-
"metadata": {},
|
|
69
|
-
"source": [
|
|
70
|
-
"**Takeaway:** Gauss-Legendre with just **5 evaluations** beats trapezoid's 100 — algorithmic intelligence beats brute force. This is the core thesis of CDS."
|
|
71
|
-
]
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
"cell_type": "markdown",
|
|
75
|
-
"id": "c42545728",
|
|
76
|
-
"metadata": {},
|
|
77
|
-
"source": [
|
|
78
|
-
"## 2 · Monte Carlo — intelligence from randomness\n",
|
|
79
|
-
"\n",
|
|
80
|
-
"Random sampling estimates $\\pi$. The error shrinks as $1/\\sqrt{N}$ — slow, but the method handles high dimensions and irregular domains where grid rules choke."
|
|
81
|
-
]
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"cell_type": "code",
|
|
85
|
-
"execution_count": null,
|
|
86
|
-
"id": "c42562368",
|
|
87
|
-
"metadata": {},
|
|
88
|
-
"outputs": [],
|
|
89
|
-
"source": [
|
|
90
|
-
"from cds.montecarlo import estimate_pi\n",
|
|
91
|
-
"\n",
|
|
92
|
-
"print(f\"{'Samples':>12} {'Estimate':>12} {'Error':>12} {'Std-err':>12}\")\n",
|
|
93
|
-
"print(\"-\" * 50)\n",
|
|
94
|
-
"for n in [1_000, 10_000, 100_000]:\n",
|
|
95
|
-
" result = estimate_pi(n_samples=n, seed=42)\n",
|
|
96
|
-
" print(\n",
|
|
97
|
-
" f\"{n:>12,} {result.estimate:>12.6f} {result.estimate - math.pi:>+12.2e} {result.std_error:>12.2e}\"\n",
|
|
98
|
-
" )"
|
|
99
|
-
]
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
"cell_type": "markdown",
|
|
103
|
-
"id": "c42562624",
|
|
104
|
-
"metadata": {},
|
|
105
|
-
"source": [
|
|
106
|
-
"## 3 · Linear Algebra — determinants scale as $O(N^3)$\n",
|
|
107
|
-
"\n",
|
|
108
|
-
"PLU decomposition computes the determinant. Doubling $N$ should multiply the cost by $\\approx 2^3 = 8$ for an $O(N^3)$ algorithm. Let's verify the complexity claim empirically."
|
|
109
|
-
]
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
"cell_type": "code",
|
|
113
|
-
"execution_count": null,
|
|
114
|
-
"id": "c42562816",
|
|
115
|
-
"metadata": {},
|
|
116
|
-
"outputs": [],
|
|
117
|
-
"source": [
|
|
118
|
-
"import time\n",
|
|
119
|
-
"\n",
|
|
120
|
-
"from cds.math_utils import determinant, identity\n",
|
|
121
|
-
"\n",
|
|
122
|
-
"\n",
|
|
123
|
-
"def make_matrix(n):\n",
|
|
124
|
-
" m = identity(n) # start from identity (a list of lists)\n",
|
|
125
|
-
" for i in range(n): # perturb so the determinant is non-trivial\n",
|
|
126
|
-
" m[i] = [1.0 / (i + j + 1) if i != j else float(n) for j in range(n)]\n",
|
|
127
|
-
" return m\n",
|
|
128
|
-
"\n",
|
|
129
|
-
"\n",
|
|
130
|
-
"def time_det(n):\n",
|
|
131
|
-
" m = make_matrix(n)\n",
|
|
132
|
-
" t0 = time.perf_counter()\n",
|
|
133
|
-
" determinant(m)\n",
|
|
134
|
-
" return time.perf_counter() - t0\n",
|
|
135
|
-
"\n",
|
|
136
|
-
"\n",
|
|
137
|
-
"t50 = time_det(50)\n",
|
|
138
|
-
"t100 = time_det(100)\n",
|
|
139
|
-
"print(f\"det(50x50) = {t50 * 1000:>8.2f} ms\")\n",
|
|
140
|
-
"print(f\"det(100x100)= {t100 * 1000:>8.2f} ms\")\n",
|
|
141
|
-
"print(f\"Ratio (doubling N): {t100 / t50:.1f}x (expected ≈ 8x for O(N³))\")"
|
|
142
|
-
]
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
"cell_type": "markdown",
|
|
146
|
-
"id": "c42545664",
|
|
147
|
-
"metadata": {},
|
|
148
|
-
"source": [
|
|
149
|
-
"## 4 · Signal Processing — FFT vs naive DFT\n",
|
|
150
|
-
"\n",
|
|
151
|
-
"The Discrete Fourier Transform is $O(N^2)$. The Fast Fourier Transform (Cooley-Tukey, radix-2) is $O(N \\log N)$. For $N=1024$ that's the difference between ~1M and ~10K operations."
|
|
152
|
-
]
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
"cell_type": "code",
|
|
156
|
-
"execution_count": null,
|
|
157
|
-
"id": "c42563392",
|
|
158
|
-
"metadata": {},
|
|
159
|
-
"outputs": [],
|
|
160
|
-
"source": [
|
|
161
|
-
"from cds.signals import dft, fft_radix2, power_spectrum\n",
|
|
162
|
-
"\n",
|
|
163
|
-
"# A signal: two sine waves\n",
|
|
164
|
-
"N = 1024\n",
|
|
165
|
-
"signal = [\n",
|
|
166
|
-
" math.sin(2 * math.pi * 5 * k / N) + 0.5 * math.sin(2 * math.pi * 13 * k / N) for k in range(N)\n",
|
|
167
|
-
"]\n",
|
|
168
|
-
"\n",
|
|
169
|
-
"t0 = time.perf_counter()\n",
|
|
170
|
-
"naive = dft(signal)\n",
|
|
171
|
-
"t_dft = time.perf_counter() - t0\n",
|
|
172
|
-
"t0 = time.perf_counter()\n",
|
|
173
|
-
"fast = fft_radix2(signal)\n",
|
|
174
|
-
"t_fft = time.perf_counter() - t0\n",
|
|
175
|
-
"\n",
|
|
176
|
-
"print(f\"Naive DFT: {t_dft * 1000:>8.2f} ms (O(N²))\")\n",
|
|
177
|
-
"print(f\"FFT radix-2:{t_fft * 1000:>8.2f} ms (O(N log N))\")\n",
|
|
178
|
-
"print(f\"Algorithmic speedup: {t_dft / t_fft:.0f}x faster\")\n",
|
|
179
|
-
"\n",
|
|
180
|
-
"mag = power_spectrum(signal)\n",
|
|
181
|
-
"peak_bin = max(range(len(mag)), key=lambda i: mag[i])\n",
|
|
182
|
-
"print(f\"Dominant frequency bin: {peak_bin} (matches the 5-cycle input)\")"
|
|
183
|
-
]
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
"cell_type": "markdown",
|
|
187
|
-
"id": "c42563648",
|
|
188
|
-
"metadata": {},
|
|
189
|
-
"source": [
|
|
190
|
-
"## 5 · Ordinary Differential Equations — the harmonic oscillator\n",
|
|
191
|
-
"\n",
|
|
192
|
-
"Solve $y'' + y = 0$ (a pure cosine) as a system. Compare a first-order method (Euler) to a fourth-order one (RK4) at the same step size — Euler drifts, RK4 stays glued to the true solution."
|
|
193
|
-
]
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
"cell_type": "code",
|
|
197
|
-
"execution_count": null,
|
|
198
|
-
"id": "c42563840",
|
|
199
|
-
"metadata": {},
|
|
200
|
-
"outputs": [],
|
|
201
|
-
"source": [
|
|
202
|
-
"from cds.diffeq import solve_system\n",
|
|
203
|
-
"\n",
|
|
204
|
-
"\n",
|
|
205
|
-
"# System: y'' = -y → state vector [y, y'] with derivative [y', -y]\n",
|
|
206
|
-
"def harmonic(t, y):\n",
|
|
207
|
-
" return [y[1], -y[0]]\n",
|
|
208
|
-
"\n",
|
|
209
|
-
"\n",
|
|
210
|
-
"t0, y0, t_end, h = 0.0, [1.0, 0.0], 6.283, 0.1 # one full period\n",
|
|
211
|
-
"\n",
|
|
212
|
-
"# solve_system uses RK4 internally — true solution is cos(t), so y[0]≈1 at t=2π\n",
|
|
213
|
-
"ts, ys = solve_system(harmonic, t0, y0, t_end, dt=h)\n",
|
|
214
|
-
"rk4_final = ys[-1][0]\n",
|
|
215
|
-
"\n",
|
|
216
|
-
"# Crude Euler for comparison: hand-rolled, same step size\n",
|
|
217
|
-
"y = list(y0)\n",
|
|
218
|
-
"for i in range(int(round((t_end - t0) / h))):\n",
|
|
219
|
-
" deriv = harmonic(0.0, y)\n",
|
|
220
|
-
" y = [yj + dj * h for yj, dj in zip(y, deriv)]\n",
|
|
221
|
-
"euler_final = y[0]\n",
|
|
222
|
-
"\n",
|
|
223
|
-
"true_final = math.cos(t_end)\n",
|
|
224
|
-
"print(f\"Euler final-position error: {euler_final - true_final:+.2e} (drifts away)\")\n",
|
|
225
|
-
"print(f\"RK4 final-position error: {rk4_final - true_final:+.2e} (stays on track)\")\n",
|
|
226
|
-
"print(\n",
|
|
227
|
-
" f\"RK4 is ~{abs((euler_final - true_final) / (rk4_final - true_final)):,.0f}x more accurate at the same step size\"\n",
|
|
228
|
-
")"
|
|
229
|
-
]
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
"cell_type": "markdown",
|
|
233
|
-
"id": "c42564096",
|
|
234
|
-
"metadata": {},
|
|
235
|
-
"source": [
|
|
236
|
-
"## 6 · Optimization — gradient descent on a bowl\n",
|
|
237
|
-
"\n",
|
|
238
|
-
"Minimize $f(x,y) = (x-3)^2 + (y+1)^2$, whose minimum is at $(3, -1)$. Gradient descent follows the slope downhill."
|
|
239
|
-
]
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
"cell_type": "code",
|
|
243
|
-
"execution_count": null,
|
|
244
|
-
"id": "c42564288",
|
|
245
|
-
"metadata": {},
|
|
246
|
-
"outputs": [],
|
|
247
|
-
"source": [
|
|
248
|
-
"from cds.optimization import gradient_descent\n",
|
|
249
|
-
"\n",
|
|
250
|
-
"\n",
|
|
251
|
-
"def bowl(coords):\n",
|
|
252
|
-
" x, y = coords\n",
|
|
253
|
-
" return (x - 3) ** 2 + (y + 1) ** 2\n",
|
|
254
|
-
"\n",
|
|
255
|
-
"\n",
|
|
256
|
-
"result = gradient_descent(bowl, [0.0, 0.0])\n",
|
|
257
|
-
"print(f\"Found minimum at {tuple(round(v, 6) for v in result.x)}\")\n",
|
|
258
|
-
"print(\"True minimum at (3.0, -1.0)\")\n",
|
|
259
|
-
"print(f\"Function value f* = {result.value:.2e} (should be ≈ 0)\")\n",
|
|
260
|
-
"print(f\"Converged in {result.iterations} iterations: {result.converged}\")"
|
|
261
|
-
]
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
"cell_type": "markdown",
|
|
265
|
-
"id": "c42564544",
|
|
266
|
-
"metadata": {},
|
|
267
|
-
"source": [
|
|
268
|
-
"## 7 · Quantum — superposition & interference\n",
|
|
269
|
-
"\n",
|
|
270
|
-
"Apply a Hadamard gate to $|0\\rangle$ to create an equal superposition, then sample measurements. Each gate below has a small, readable implementation you can find in `src/cds/quantum/`."
|
|
271
|
-
]
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
"cell_type": "code",
|
|
275
|
-
"execution_count": null,
|
|
276
|
-
"id": "c42564736",
|
|
277
|
-
"metadata": {},
|
|
278
|
-
"outputs": [],
|
|
279
|
-
"source": [
|
|
280
|
-
"from cds.quantum import QuantumCircuit, hadamard, simulate\n",
|
|
281
|
-
"\n",
|
|
282
|
-
"circuit = QuantumCircuit().add(hadamard()) # |0⟩ → (|0⟩ + |1⟩)/√2\n",
|
|
283
|
-
"result = circuit.run()\n",
|
|
284
|
-
"probs = result.probabilities()\n",
|
|
285
|
-
"print(f\"Probabilities: |0⟩ → {probs[0]:.3f}, |1⟩ → {probs[1]:.3f}\")\n",
|
|
286
|
-
"\n",
|
|
287
|
-
"counts = simulate(circuit, shots=10000)\n",
|
|
288
|
-
"print(f\"Measurement (10k shots): {counts}\")\n",
|
|
289
|
-
"print(\"Each outcome lands near 50% — the hallmark of superposition.\")"
|
|
290
|
-
]
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
"cell_type": "markdown",
|
|
294
|
-
"id": "",
|
|
295
|
-
"metadata": {},
|
|
296
|
-
"source": [
|
|
297
|
-
"## 8 · Two-Dimensional Integration — the tensor product, and the curse of dimension\n",
|
|
298
|
-
"\n",
|
|
299
|
-
"A 1-D rule extends to a rectangle by the **tensor product**: integrate in $x$ with a rule, then integrate *that result* in $y$. The catch is that work multiplies too — an $n\times n$ grid costs $n^2$ evaluations, and in $d$ dimensions a full grid needs $n^d$. So, just as in stop 1, *high-order* rules pay off: a few well-placed points beat many evenly-spaced ones."
|
|
300
|
-
]
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
"cell_type": "code",
|
|
304
|
-
"execution_count": null,
|
|
305
|
-
"id": "",
|
|
306
|
-
"metadata": {},
|
|
307
|
-
"outputs": [],
|
|
308
|
-
"source": [
|
|
309
|
-
"import math\n",
|
|
310
|
-
"\n",
|
|
311
|
-
"from cds.numerical_integration import gaussian_quadrature_2d, simpson_2d\n",
|
|
312
|
-
"\n",
|
|
313
|
-
"\n",
|
|
314
|
-
"# ∬_{[0,1]²} x² y² dx dy = (1/3)·(1/3) = 1/9 — exact for both rules.\n",
|
|
315
|
-
"def poly(x, y):\n",
|
|
316
|
-
" return x * x * y * y\n",
|
|
317
|
-
"\n",
|
|
318
|
-
"\n",
|
|
319
|
-
"true_poly = 1.0 / 9.0\n",
|
|
320
|
-
"\n",
|
|
321
|
-
"\n",
|
|
322
|
-
"# Area of the unit disk ∬_{[-1,1]²} 1_{x²+y²≤1} dx dy should be π.\n",
|
|
323
|
-
"def disk(x, y):\n",
|
|
324
|
-
" return 1.0 if x * x + y * y <= 1.0 else 0.0\n",
|
|
325
|
-
"\n",
|
|
326
|
-
"\n",
|
|
327
|
-
"print(f\"Simpson 2-D poly err = {simpson_2d(poly, 0, 1, 0, 1, 2, 2) - true_poly:+.2e}\")\n",
|
|
328
|
-
"print(f\"Gauss-3 2-D poly err = {gaussian_quadrature_2d(poly, 0, 1, 0, 1, n=3) - true_poly:+.2e}\")\n",
|
|
329
|
-
"print(f\"Simpson 2-D disk = {simpson_2d(disk, -1, 1, -1, 1, 100, 100):.5f} (π = 3.14159)\")"
|
|
330
|
-
]
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
"cell_type": "markdown",
|
|
334
|
-
"id": "",
|
|
335
|
-
"metadata": {},
|
|
336
|
-
"source": [
|
|
337
|
-
"**Takeaway:** both rules nail the smooth polynomial exactly (Simpson through cubics per axis, 3-point Gauss through degree 5). But the *disk* — a discontinuous indicator — still only reaches three decimals of $\\pi$ from a $100\times100 = 10{,}000$-point grid, because evaluations straddling the curved edge are wasted. As dimensions grow, the tensor-product grid explodes as $n^d$ — the precise pain Monte Carlo (stop 2) sidesteps."
|
|
338
|
-
]
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
"cell_type": "code",
|
|
342
|
-
"execution_count": null,
|
|
343
|
-
"id": "",
|
|
344
|
-
"metadata": {},
|
|
345
|
-
"outputs": [],
|
|
346
|
-
"source": [
|
|
347
|
-
"# See it explode: evaluations needed for a 2-D grid vs a 3-D grid at the same per-axis n.\n",
|
|
348
|
-
"for d in (1, 2, 3, 4, 5):\n",
|
|
349
|
-
" print(f\"d={d}: n=20 per axis -> {20**d:>12,} evaluations\")"
|
|
350
|
-
]
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
"cell_type": "markdown",
|
|
354
|
-
"id": "",
|
|
355
|
-
"metadata": {},
|
|
356
|
-
"source": [
|
|
357
|
-
"## 9 · Time-Series — structure in the order\n",
|
|
358
|
-
"\n",
|
|
359
|
-
"Strip away the time index and a series is just numbers. Put it back, and *order* starts to matter: yesterday's value predicts today's. The **autocorrelation function** (ACF) measures exactly how much, at every lag, and the Ljung–Box test asks whether *any* of those correlations are real signal rather than noise."
|
|
360
|
-
]
|
|
361
|
-
},
|
|
362
|
-
{
|
|
363
|
-
"cell_type": "code",
|
|
364
|
-
"execution_count": null,
|
|
365
|
-
"id": "",
|
|
366
|
-
"metadata": {},
|
|
367
|
-
"outputs": [],
|
|
368
|
-
"source": [
|
|
369
|
-
"import random\n",
|
|
370
|
-
"\n",
|
|
371
|
-
"from cds.stats import autocorrelation_function, ljung_box\n",
|
|
372
|
-
"\n",
|
|
373
|
-
"random.seed(0)\n",
|
|
374
|
-
"N = 240\n",
|
|
375
|
-
"signal = [random.gauss(0.0, 1.0) for _ in range(N)] # white-noise base...\n",
|
|
376
|
-
"for k in range(4, N): # ...plus a lag-4 echo:\n",
|
|
377
|
-
" signal[k] += 0.6 * signal[k - 4] # each value repeats 4 steps back\n",
|
|
378
|
-
"\n",
|
|
379
|
-
"acf = autocorrelation_function(signal, max_lag=16)\n",
|
|
380
|
-
"print(f\"r[1] = {acf[1]:+.3f} (no lag-1 structure)\")\n",
|
|
381
|
-
"print(f\"r[4] = {acf[4]:+.3f} (lag-4 echo peaks here)\")\n",
|
|
382
|
-
"print(f\"r[8] = {acf[8]:+.3f} (echo of the echo)\")\n",
|
|
383
|
-
"lb = ljung_box(signal, lags=12)\n",
|
|
384
|
-
"print(f\"Ljung-Box p-value = {lb.p_value:.2e} -> autocorrelation present? {lb.has_autocorrelation}\")"
|
|
385
|
-
]
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
"cell_type": "markdown",
|
|
389
|
-
"id": "",
|
|
390
|
-
"metadata": {},
|
|
391
|
-
"source": [
|
|
392
|
-
"**Takeaway:** the ACF is flat near zero *except* at lag 4 — exactly where we injected the echo — with a smaller secondary bump at lag 8 (each echo repeats its own predecessor). The Ljung–Box test aggregates the first dozen autocorrelations into one statistic and finds overwhelming evidence they are not all zero. This is step one of any Box–Jenkins workflow: detect structure, then model it. CDS also offers the partial ACF, KPSS-style stationarity testing, and seasonal decomposition."
|
|
393
|
-
]
|
|
394
|
-
},
|
|
395
|
-
{
|
|
396
|
-
"cell_type": "code",
|
|
397
|
-
"execution_count": null,
|
|
398
|
-
"id": "",
|
|
399
|
-
"metadata": {},
|
|
400
|
-
"outputs": [],
|
|
401
|
-
"source": [
|
|
402
|
-
"# Differencing at the echo lag kills the autocorrelation -> the series becomes white-ish noise.\n",
|
|
403
|
-
"from cds.stats import difference\n",
|
|
404
|
-
"\n",
|
|
405
|
-
"diffed = difference(signal, lag=4)\n",
|
|
406
|
-
"acf_d = autocorrelation_function(diffed, max_lag=16)\n",
|
|
407
|
-
"print(f\"after differencing: r[4] = {acf_d[4]:+.3f} (was {acf[4]:+.3f})\")"
|
|
408
|
-
]
|
|
409
|
-
},
|
|
410
|
-
{
|
|
411
|
-
"cell_type": "markdown",
|
|
412
|
-
"id": "",
|
|
413
|
-
"metadata": {},
|
|
414
|
-
"source": [
|
|
415
|
-
"## 10 · Filter Design — maximally flat, from scratch\n",
|
|
416
|
-
"\n",
|
|
417
|
-
"A filter's job is to pass some frequencies and stop others. The **Butterworth** family does this with the flattest possible passband — no ripple — which is why it's the default \"honest\" filter. Designing one means placing poles on a circle (analog prototype), warping them to the digital domain (bilinear transform), and reading off difference-equation coefficients — all derived from first principles in CDS."
|
|
418
|
-
]
|
|
419
|
-
},
|
|
420
|
-
{
|
|
421
|
-
"cell_type": "code",
|
|
422
|
-
"execution_count": null,
|
|
423
|
-
"id": "",
|
|
424
|
-
"metadata": {},
|
|
425
|
-
"outputs": [],
|
|
426
|
-
"source": [
|
|
427
|
-
"import math\n",
|
|
428
|
-
"\n",
|
|
429
|
-
"from cds.signals import apply_filter, butter_lowpass\n",
|
|
430
|
-
"\n",
|
|
431
|
-
"# A slow 5-cycle sine plus faster 200-cycle interference, sampled at N points.\n",
|
|
432
|
-
"# Normalised freq = (cycles) / (N/2): k=5 -> 0.010, k=200 -> 0.391.\n",
|
|
433
|
-
"N = 1024\n",
|
|
434
|
-
"clean = [math.sin(2 * math.pi * 5 * k / N) for k in range(N)]\n",
|
|
435
|
-
"high = [0.6 * math.sin(2 * math.pi * 200 * k / N) for k in range(N)]\n",
|
|
436
|
-
"noisy = [a + b for a, b in zip(clean, high)]\n",
|
|
437
|
-
"\n",
|
|
438
|
-
"coef = butter_lowpass(order=4, cutoff=0.15) # keep freqs below 15% of Nyquist\n",
|
|
439
|
-
"filtered = apply_filter(noisy, coef)\n",
|
|
440
|
-
"\n",
|
|
441
|
-
"# Cosine similarity in the steady-state half (phase-robust): 1.0 = perfect recovery.\n",
|
|
442
|
-
"half = N // 2\n",
|
|
443
|
-
"dot = sum(clean[i] * filtered[i] for i in range(half, N))\n",
|
|
444
|
-
"norm = math.sqrt(sum(c * c for c in clean[half:]) * sum(f * f for f in filtered[half:]))\n",
|
|
445
|
-
"print(f\"recovery (cos sim vs clean) = {dot / norm:.3f} (1.000 = perfect)\")\n",
|
|
446
|
-
"# Attenuation of the interference alone: pass it through and compare amplitudes.\n",
|
|
447
|
-
"attenuated = apply_filter([math.sin(2 * math.pi * 200 * k / N) for k in range(N)], coef)\n",
|
|
448
|
-
"a_in = 1.0\n",
|
|
449
|
-
"a_out = max(abs(x) for x in attenuated[half:])\n",
|
|
450
|
-
"print(\n",
|
|
451
|
-
" f\"interference amplitude: {a_in:.3f} -> {a_out:.4f} ({a_in / max(a_out, 1e-12):.0f}x smaller)\"\n",
|
|
452
|
-
")"
|
|
453
|
-
]
|
|
454
|
-
},
|
|
455
|
-
{
|
|
456
|
-
"cell_type": "markdown",
|
|
457
|
-
"id": "",
|
|
458
|
-
"metadata": {},
|
|
459
|
-
"source": [
|
|
460
|
-
"**Takeaway:** the slow signal passes through almost untouched (cosine similarity $\u0007pprox 0.99$), while the 200-cycle interference is crushed ~74× ($-37$ dB). That selectivity comes from a 4th-order polynomial whose poles sit on a circle. The same module adds high-pass, band-pass (cascade), band-stop (parallel), and a `moving_median` denoiser that shrugs off impulsive outliers the way no linear filter can."
|
|
461
|
-
]
|
|
462
|
-
},
|
|
463
|
-
{
|
|
464
|
-
"cell_type": "markdown",
|
|
465
|
-
"id": "c42564864",
|
|
466
|
-
"metadata": {},
|
|
467
|
-
"source": [
|
|
468
|
-
"---\n",
|
|
469
|
-
"\n",
|
|
470
|
-
"## 🎓 Where next?\n",
|
|
471
|
-
"\n",
|
|
472
|
-
"Every algorithm above is **implemented from scratch** in `src/cds/` — readable Python you can step through line by line. To go deeper:\n",
|
|
473
|
-
"\n",
|
|
474
|
-
"- 📖 [Full API reference](https://furox-art.github.io/scientific-computing-system/api/)\n",
|
|
475
|
-
"- 🎓 [Per-module tutorials](https://furox-art.github.io/scientific-computing-system/tutorials/quick_start/)\n",
|
|
476
|
-
"- 🔬 [Case study: measuring the Hubble constant](https://furox-art.github.io/scientific-computing-system/CASE_STUDY_HUBBLE/)\n",
|
|
477
|
-
"\n",
|
|
478
|
-
"If this tour was useful, a ⭐ on the [repo](https://github.com/Furox-Art/scientific-computing-system) helps others find it.\n",
|
|
479
|
-
"\n",
|
|
480
|
-
"> **Experiment:** change the function in §1, raise $N$ in §2, or add gates in §7. Nothing here is locked — that's the point of pure, readable code."
|
|
481
|
-
]
|
|
482
|
-
}
|
|
483
|
-
],
|
|
484
|
-
"metadata": {
|
|
485
|
-
"kernelspec": {
|
|
486
|
-
"display_name": "Python 3",
|
|
487
|
-
"language": "python",
|
|
488
|
-
"name": "python3"
|
|
489
|
-
},
|
|
490
|
-
"language_info": {
|
|
491
|
-
"name": "python",
|
|
492
|
-
"version": "3.10"
|
|
493
|
-
}
|
|
494
|
-
},
|
|
495
|
-
"nbformat": 4,
|
|
496
|
-
"nbformat_minor": 5
|
|
497
|
-
}
|
package/mkdocs.yml
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
site_name: Scientific Computing System
|
|
2
|
-
site_url: https://furox-art.github.io/scientific-computing-system/
|
|
3
|
-
site_description: >-
|
|
4
|
-
Pure-Python computational science platform - quantum simulation, FFT,
|
|
5
|
-
linear algebra, statistics, ODEs, symbolic math and ML from scratch,
|
|
6
|
-
with zero runtime dependencies.
|
|
7
|
-
site_author: Furox-Art
|
|
8
|
-
repo_url: https://github.com/Furox-Art/scientific-computing-system
|
|
9
|
-
repo_name: Furox-Art/scientific-computing-system
|
|
10
|
-
edit_uri: edit/main/docs/
|
|
11
|
-
copyright: Released under the MIT License
|
|
12
|
-
|
|
13
|
-
theme:
|
|
14
|
-
name: material
|
|
15
|
-
logo: assets/icon.svg
|
|
16
|
-
favicon: assets/icon.svg
|
|
17
|
-
icon:
|
|
18
|
-
repo: fontawesome/brands/github
|
|
19
|
-
palette:
|
|
20
|
-
- media: "(prefers-color-scheme: light)"
|
|
21
|
-
scheme: default
|
|
22
|
-
primary: teal
|
|
23
|
-
accent: cyan
|
|
24
|
-
toggle:
|
|
25
|
-
icon: material/brightness-7
|
|
26
|
-
name: Switch to dark mode
|
|
27
|
-
- media: "(prefers-color-scheme: dark)"
|
|
28
|
-
scheme: slate
|
|
29
|
-
primary: teal
|
|
30
|
-
accent: cyan
|
|
31
|
-
toggle:
|
|
32
|
-
icon: material/brightness-4
|
|
33
|
-
name: Switch to light mode
|
|
34
|
-
features:
|
|
35
|
-
- navigation.tabs
|
|
36
|
-
- navigation.tabs.sticky
|
|
37
|
-
- navigation.sections
|
|
38
|
-
- navigation.indexes
|
|
39
|
-
- navigation.top
|
|
40
|
-
- navigation.tracking
|
|
41
|
-
- toc.follow
|
|
42
|
-
- search.suggest
|
|
43
|
-
- search.highlight
|
|
44
|
-
- search.share
|
|
45
|
-
- content.code.copy
|
|
46
|
-
- content.code.annotate
|
|
47
|
-
- content.action.edit
|
|
48
|
-
- content.tabs.link
|
|
49
|
-
|
|
50
|
-
extra_css:
|
|
51
|
-
- stylesheets/extra.css
|
|
52
|
-
|
|
53
|
-
extra:
|
|
54
|
-
social:
|
|
55
|
-
- icon: fontawesome/brands/github
|
|
56
|
-
link: https://github.com/Furox-Art/scientific-computing-system
|
|
57
|
-
name: Source on GitHub
|
|
58
|
-
- icon: fontawesome/brands/python
|
|
59
|
-
link: https://pypi.org/project/scientific-computing-system/
|
|
60
|
-
name: scientific-computing-system on PyPI
|
|
61
|
-
|
|
62
|
-
plugins:
|
|
63
|
-
- search
|
|
64
|
-
- mkdocstrings:
|
|
65
|
-
default_handler: python
|
|
66
|
-
handlers:
|
|
67
|
-
python:
|
|
68
|
-
options:
|
|
69
|
-
show_source: true
|
|
70
|
-
show_root_heading: true
|
|
71
|
-
show_category_heading: true
|
|
72
|
-
show_symbol_type_heading: true
|
|
73
|
-
show_symbol_type_toc: true
|
|
74
|
-
members_order: source
|
|
75
|
-
separate_signature: true
|
|
76
|
-
show_signature_annotations: true
|
|
77
|
-
|
|
78
|
-
nav:
|
|
79
|
-
- Home: index.md
|
|
80
|
-
- Getting Started:
|
|
81
|
-
- Install & First Steps: getting-started.md
|
|
82
|
-
- Tour of Numerical Methods: tour_of_numerical_methods.md
|
|
83
|
-
- Quick Start Tutorial: tutorials/quick_start.md
|
|
84
|
-
- Tutorials:
|
|
85
|
-
- Foundations:
|
|
86
|
-
- Core Data Models: tutorials/core_demo.md
|
|
87
|
-
- Scientific Formulas: tutorials/scientific_demo.md
|
|
88
|
-
- Math Utilities: tutorials/math_utils_demo.md
|
|
89
|
-
- Linear Algebra: tutorials/linalg_demo.md
|
|
90
|
-
- Numerical Methods:
|
|
91
|
-
- Numerical Integration: tutorials/numerical_integration_demo.md
|
|
92
|
-
- Differential Equations: tutorials/diffeq_demo.md
|
|
93
|
-
- Stiff ODE Solvers: tutorials/stiff_ode_demo.md
|
|
94
|
-
- Optimization: tutorials/optimization_demo.md
|
|
95
|
-
- Probability & Statistics:
|
|
96
|
-
- Probability: tutorials/probability_demo.md
|
|
97
|
-
- Monte Carlo: tutorials/montecarlo_demo.md
|
|
98
|
-
- Statistics: tutorials/stats_demo.md
|
|
99
|
-
- Hypothesis Testing: tutorials/hypothesis_tests_demo.md
|
|
100
|
-
- Time-Series Analysis: tutorials/time_series_demo.md
|
|
101
|
-
- Signals & Quantum:
|
|
102
|
-
- Signal Processing: tutorials/signals_demo.md
|
|
103
|
-
- 2-D FFT: tutorials/fft2_demo.md
|
|
104
|
-
- Quantum Lab: tutorials/quantum_demo.md
|
|
105
|
-
- Machine Learning:
|
|
106
|
-
- Machine Learning: tutorials/ml_demo.md
|
|
107
|
-
- Machine Learning + Viz: tutorials/ml_and_viz_demo.md
|
|
108
|
-
- Advanced ML — PCA & Classic Models: tutorials/ml_advanced_demo.md
|
|
109
|
-
- PCA End-to-End + Preprocessing: tutorials/pca_demo.md
|
|
110
|
-
- Natural Language Processing:
|
|
111
|
-
- BPE & Embeddings: tutorials/nlp_bpe_demo.md
|
|
112
|
-
- Attention: tutorials/nlp_attention_demo.md
|
|
113
|
-
- MiniGPT: tutorials/nlp_mini_gpt_demo.md
|
|
114
|
-
- Visualisation: tutorials/nlp_viz.md
|
|
115
|
-
- Data & Knowledge:
|
|
116
|
-
- Data Analysis: tutorials/data_analysis_demo.md
|
|
117
|
-
- Pandas Interoperability: tutorials/pandas_io_demo.md
|
|
118
|
-
- Graph Algorithms: tutorials/graph_demo.md
|
|
119
|
-
- Mathematical Modeling: tutorials/modeling_demo.md
|
|
120
|
-
- Knowledge Organization: tutorials/knowledge_demo.md
|
|
121
|
-
- Hypothesis Engine:
|
|
122
|
-
- Hypothesis Engine: tutorials/hypothesis_demo.md
|
|
123
|
-
- Hypothesis + Stats: tutorials/hypothesis_with_stats_demo.md
|
|
124
|
-
- Reference:
|
|
125
|
-
- API Reference: api.md
|
|
126
|
-
- Cookbook: cookbook.md
|
|
127
|
-
- ML Reference Values: ml_reference.md
|
|
128
|
-
- Architecture: ARCHITECTURE.md
|
|
129
|
-
- Research:
|
|
130
|
-
- Research Workflows: research-workflows.md
|
|
131
|
-
- Case Studies:
|
|
132
|
-
- Hubble Tension: CASE_STUDY_HUBBLE.md
|
|
133
|
-
- Quantum-ML: CASE_STUDY_QUANTUM_ML.md
|
|
134
|
-
- Performance: benchmarks.md
|
|
135
|
-
- Maintenance: maintenance.md
|
|
136
|
-
|
|
137
|
-
markdown_extensions:
|
|
138
|
-
- admonition
|
|
139
|
-
- attr_list
|
|
140
|
-
- md_in_html
|
|
141
|
-
- def_list
|
|
142
|
-
- footnotes
|
|
143
|
-
- tables
|
|
144
|
-
- toc:
|
|
145
|
-
permalink: true
|
|
146
|
-
toc_depth: 3
|
|
147
|
-
- pymdownx.details
|
|
148
|
-
- pymdownx.highlight:
|
|
149
|
-
anchor_linenums: true
|
|
150
|
-
- pymdownx.inlinehilite
|
|
151
|
-
- pymdownx.snippets
|
|
152
|
-
- pymdownx.superfences
|
|
153
|
-
- pymdownx.tabbed:
|
|
154
|
-
alternate_style: true
|
|
155
|
-
- pymdownx.arithmatex:
|
|
156
|
-
generic: true
|
|
157
|
-
|
|
158
|
-
extra_javascript:
|
|
159
|
-
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
|