scientific-computing-system 1.0.0 → 2.2.0

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.
Files changed (430) hide show
  1. package/CHANGELOG.md +284 -0
  2. package/LICENSE +0 -0
  3. package/README.md +89 -218
  4. package/SECURITY.md +0 -0
  5. package/bin/scs.js +12 -2
  6. package/index.js +115 -1
  7. package/package.json +45 -1
  8. package/.binder/postBuild +0 -9
  9. package/.binder/requirements.txt +0 -10
  10. package/.gitattributes +0 -35
  11. package/.github/CODEOWNERS +0 -4
  12. package/.github/FUNDING.yml +0 -3
  13. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -50
  14. package/.github/ISSUE_TEMPLATE/config.yml +0 -8
  15. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -28
  16. package/.github/PULL_REQUEST_TEMPLATE.md +0 -29
  17. package/.github/dependabot.yml +0 -32
  18. package/.github/labeler.yml +0 -50
  19. package/.github/workflows/benchmarks.yml +0 -97
  20. package/.github/workflows/bot-reviewer.yml +0 -58
  21. package/.github/workflows/changelog.yml +0 -130
  22. package/.github/workflows/cli-package-smoke.yml +0 -45
  23. package/.github/workflows/codeql.yml +0 -55
  24. package/.github/workflows/npm-publish.yml +0 -33
  25. package/.github/workflows/p08-cancel-noncanonical-runs.yml +0 -41
  26. package/.github/workflows/pr-automation.yml +0 -78
  27. package/.github/workflows/public-external-validation-p08-v2-glm.yml +0 -161
  28. package/.github/workflows/public-external-validation-p08-v2-recovery-merge-gate.yml +0 -72
  29. package/.github/workflows/public-external-validation-p08-v2-recovery-merge.yml +0 -113
  30. package/.github/workflows/public-external-validation-p08-v2-run-recovery-anatomy-gate.yml +0 -57
  31. package/.github/workflows/public-external-validation-p08-v2-run-recovery-merge-gate.yml +0 -63
  32. package/.github/workflows/public-external-validation-p08-v2-run-recovery-merge.yml +0 -89
  33. package/.github/workflows/public-external-validation-p08-v2-run-recovery.yml +0 -182
  34. package/.github/workflows/public-external-validation-p08-v3-glm-gate.yml +0 -67
  35. package/.github/workflows/public-external-validation-p08-v4-recovery-glm-gate.yml +0 -78
  36. package/.github/workflows/public-external-validation-p08-v4-recovery-glm.yml +0 -248
  37. package/.github/workflows/public-external-validation-p08-v5-run-recovery-glm-gate.yml +0 -66
  38. package/.github/workflows/public-external-validation-p08-v5-run-recovery-glm.yml +0 -218
  39. package/.github/workflows/pypi-registry-smoke.yml +0 -116
  40. package/.github/workflows/release.yml +0 -359
  41. package/.github/workflows/tests.yml +0 -250
  42. package/.github/workflows/tmp-compassion-raw-acquire.yml +0 -63
  43. package/.github/workflows/wsl-science-runner-smoke.yml +0 -45
  44. package/.pre-commit-config.yaml +0 -48
  45. package/CITATION.cff +0 -29
  46. package/CODE_OF_CONDUCT.md +0 -25
  47. package/CONTRIBUTING.md +0 -275
  48. package/ROADMAP.md +0 -155
  49. package/assets/logo.svg +0 -38
  50. package/assets/social_preview.png +0 -0
  51. package/benchmarks/results.json +0 -43
  52. package/benchmarks/robust_runner.py +0 -118
  53. package/benchmarks/run_benchmarks.py +0 -394
  54. package/cliff.toml +0 -100
  55. package/dashboard/app.py +0 -224
  56. package/docs/ARCHITECTURE.md +0 -252
  57. package/docs/CASE_STUDY_HUBBLE.md +0 -78
  58. package/docs/CASE_STUDY_QUANTUM_ML.md +0 -79
  59. package/docs/api.md +0 -133
  60. package/docs/assets/icon.svg +0 -17
  61. package/docs/assets/logo.svg +0 -38
  62. package/docs/benchmarks.md +0 -62
  63. package/docs/cookbook.md +0 -930
  64. package/docs/getting-started.md +0 -185
  65. package/docs/index.md +0 -111
  66. package/docs/maintenance.md +0 -61
  67. package/docs/ml_reference.md +0 -92
  68. package/docs/research-workflows.md +0 -82
  69. package/docs/stylesheets/extra.css +0 -122
  70. package/docs/tour_of_numerical_methods.md +0 -330
  71. package/docs/tutorials/core_demo.md +0 -35
  72. package/docs/tutorials/data_analysis_demo.md +0 -43
  73. package/docs/tutorials/diffeq_demo.md +0 -48
  74. package/docs/tutorials/fft2_demo.md +0 -67
  75. package/docs/tutorials/graph_demo.md +0 -45
  76. package/docs/tutorials/hypothesis_demo.md +0 -44
  77. package/docs/tutorials/hypothesis_tests_demo.md +0 -170
  78. package/docs/tutorials/hypothesis_with_stats_demo.md +0 -80
  79. package/docs/tutorials/knowledge_demo.md +0 -114
  80. package/docs/tutorials/linalg_demo.md +0 -103
  81. package/docs/tutorials/math_utils_demo.md +0 -46
  82. package/docs/tutorials/ml_advanced_demo.md +0 -96
  83. package/docs/tutorials/ml_and_viz_demo.md +0 -93
  84. package/docs/tutorials/ml_demo.md +0 -70
  85. package/docs/tutorials/modeling_demo.md +0 -82
  86. package/docs/tutorials/montecarlo_demo.md +0 -42
  87. package/docs/tutorials/nlp_attention_demo.md +0 -107
  88. package/docs/tutorials/nlp_bpe_demo.md +0 -103
  89. package/docs/tutorials/nlp_mini_gpt_demo.md +0 -110
  90. package/docs/tutorials/nlp_viz.md +0 -76
  91. package/docs/tutorials/numerical_integration_demo.md +0 -65
  92. package/docs/tutorials/optimization_demo.md +0 -106
  93. package/docs/tutorials/pandas_io_demo.md +0 -160
  94. package/docs/tutorials/pca_demo.md +0 -87
  95. package/docs/tutorials/probability_demo.md +0 -48
  96. package/docs/tutorials/quantum_demo.md +0 -31
  97. package/docs/tutorials/quick_start.md +0 -44
  98. package/docs/tutorials/scientific_demo.md +0 -46
  99. package/docs/tutorials/signals_demo.md +0 -167
  100. package/docs/tutorials/stats_demo.md +0 -94
  101. package/docs/tutorials/stiff_ode_demo.md +0 -84
  102. package/docs/tutorials/time_series_demo.md +0 -145
  103. package/examples/core_demo.py +0 -40
  104. package/examples/data_analysis_demo.py +0 -60
  105. package/examples/diffeq_demo.py +0 -34
  106. package/examples/discovery_pipeline_demo.py +0 -57
  107. package/examples/ensemble_showcase.py +0 -81
  108. package/examples/fft2_demo.py +0 -32
  109. package/examples/graph_demo.py +0 -49
  110. package/examples/hypothesis_custom_generator.py +0 -121
  111. package/examples/hypothesis_demo.py +0 -48
  112. package/examples/hypothesis_tests_demo.py +0 -52
  113. package/examples/hypothesis_with_stats_demo.py +0 -43
  114. package/examples/interpolate_demo.py +0 -57
  115. package/examples/knowledge_demo.py +0 -100
  116. package/examples/linalg_demo.py +0 -61
  117. package/examples/math_utils_demo.py +0 -53
  118. package/examples/ml_and_viz_demo.py +0 -47
  119. package/examples/modeling_demo.py +0 -110
  120. package/examples/montecarlo_demo.py +0 -41
  121. package/examples/nlp_attention_demo.py +0 -168
  122. package/examples/nlp_bpe_demo.py +0 -79
  123. package/examples/nlp_mini_gpt_demo.py +0 -76
  124. package/examples/nlp_viz_demo.py +0 -98
  125. package/examples/numerical_integration_demo.py +0 -60
  126. package/examples/optimization_demo.py +0 -34
  127. package/examples/pca_demo.py +0 -124
  128. package/examples/pde_demo.py +0 -65
  129. package/examples/plot_demo.py +0 -84
  130. package/examples/plotting_notebook.ipynb +0 -87
  131. package/examples/probability_demo.py +0 -39
  132. package/examples/quantum_demo.py +0 -42
  133. package/examples/scientific_demo.py +0 -49
  134. package/examples/signals_demo.py +0 -86
  135. package/examples/stats_demo.py +0 -40
  136. package/examples/tour_of_numerical_methods.ipynb +0 -497
  137. package/mkdocs.yml +0 -159
  138. package/pyproject.toml +0 -288
  139. package/requirements-dev.lock +0 -427
  140. package/requirements-dev.txt +0 -39
  141. package/requirements.lock +0 -6
  142. package/requirements.txt +0 -13
  143. package/scripts/build_gif.py +0 -111
  144. package/scripts/build_video.py +0 -214
  145. package/scripts/cleanup_deployments.py +0 -173
  146. package/scripts/crop_readme_png.py +0 -40
  147. package/scripts/make_pi_dashboard.py +0 -316
  148. package/scripts/make_pi_gif.py +0 -138
  149. package/scripts/publish.py +0 -203
  150. package/scripts/render_promo.mjs +0 -93
  151. package/scripts/render_readme.py +0 -211
  152. package/scripts/render_readme_sections.py +0 -168
  153. package/scripts/verify_cli_install.py +0 -99
  154. package/scripts/verify_cookbook.py +0 -601
  155. package/scripts/verify_d1_numerics.py +0 -504
  156. package/scripts/verify_d2_edge_cases.py +0 -442
  157. package/scripts/verify_d4_hypothesis.py +0 -337
  158. package/scripts/verify_ml_reference.py +0 -160
  159. package/scripts/verify_pypi_release.py +0 -97
  160. package/scripts/verify_release_integrity.py +0 -194
  161. package/src/cds/__init__.py +0 -132
  162. package/src/cds/__main__.py +0 -8
  163. package/src/cds/_version.py +0 -11
  164. package/src/cds/bayes/__init__.py +0 -25
  165. package/src/cds/bayes/conjugate.py +0 -560
  166. package/src/cds/cli/__init__.py +0 -104
  167. package/src/cds/cli/__main__.py +0 -8
  168. package/src/cds/cli/_handlers.py +0 -323
  169. package/src/cds/cli/_parser.py +0 -155
  170. package/src/cds/cli/_style.py +0 -208
  171. package/src/cds/cli/_system_info.py +0 -71
  172. package/src/cds/core/__init__.py +0 -5
  173. package/src/cds/core/_numeric.py +0 -92
  174. package/src/cds/core/models.py +0 -166
  175. package/src/cds/data_analysis/__init__.py +0 -30
  176. package/src/cds/data_analysis/dataset.py +0 -122
  177. package/src/cds/data_analysis/loader.py +0 -75
  178. package/src/cds/data_analysis/pandas_io.py +0 -108
  179. package/src/cds/data_analysis/transform.py +0 -36
  180. package/src/cds/data_analysis/viz.py +0 -88
  181. package/src/cds/data_io/__init__.py +0 -27
  182. package/src/cds/data_io/streaming.py +0 -314
  183. package/src/cds/diffeq/__init__.py +0 -37
  184. package/src/cds/diffeq/_implicit.py +0 -349
  185. package/src/cds/diffeq/solvers.py +0 -312
  186. package/src/cds/diffeq/symplectic.py +0 -225
  187. package/src/cds/fractals/__init__.py +0 -34
  188. package/src/cds/fractals/sets.py +0 -356
  189. package/src/cds/genetics/__init__.py +0 -22
  190. package/src/cds/genetics/sequence.py +0 -199
  191. package/src/cds/graph/__init__.py +0 -31
  192. package/src/cds/graph/algorithms.py +0 -399
  193. package/src/cds/hypothesis/__init__.py +0 -51
  194. package/src/cds/hypothesis/evaluator.py +0 -311
  195. package/src/cds/hypothesis/generator.py +0 -275
  196. package/src/cds/hypothesis/mining.py +0 -314
  197. package/src/cds/infotheory/__init__.py +0 -25
  198. package/src/cds/infotheory/measures.py +0 -276
  199. package/src/cds/interpolate/__init__.py +0 -156
  200. package/src/cds/knowledge/__init__.py +0 -45
  201. package/src/cds/knowledge/graph.py +0 -489
  202. package/src/cds/knowledge/notes.py +0 -231
  203. package/src/cds/knowledge/retrieval.py +0 -339
  204. package/src/cds/math_utils/__init__.py +0 -46
  205. package/src/cds/math_utils/calculus.py +0 -40
  206. package/src/cds/math_utils/linalg.py +0 -496
  207. package/src/cds/math_utils/special.py +0 -167
  208. package/src/cds/math_utils/svd.py +0 -261
  209. package/src/cds/ml/__init__.py +0 -60
  210. package/src/cds/ml/boosting.py +0 -304
  211. package/src/cds/ml/clustering.py +0 -190
  212. package/src/cds/ml/decomposition.py +0 -172
  213. package/src/cds/ml/ensemble.py +0 -152
  214. package/src/cds/ml/linear_models.py +0 -225
  215. package/src/cds/ml/metrics.py +0 -227
  216. package/src/cds/ml/model_selection.py +0 -150
  217. package/src/cds/ml/naive_bayes.py +0 -179
  218. package/src/cds/ml/neighbors.py +0 -162
  219. package/src/cds/ml/neural.py +0 -204
  220. package/src/cds/ml/preprocessing.py +0 -131
  221. package/src/cds/ml/tree.py +0 -228
  222. package/src/cds/ml/voting.py +0 -175
  223. package/src/cds/modeling/__init__.py +0 -44
  224. package/src/cds/modeling/_base.py +0 -210
  225. package/src/cds/modeling/_nodes.py +0 -526
  226. package/src/cds/modeling/expression.py +0 -81
  227. package/src/cds/modeling/fitting.py +0 -477
  228. package/src/cds/modeling/model.py +0 -134
  229. package/src/cds/modeling/solver.py +0 -187
  230. package/src/cds/montecarlo/__init__.py +0 -24
  231. package/src/cds/montecarlo/markov.py +0 -112
  232. package/src/cds/montecarlo/methods.py +0 -294
  233. package/src/cds/nlp/__init__.py +0 -170
  234. package/src/cds/nlp/attention.py +0 -285
  235. package/src/cds/nlp/autograd/__init__.py +0 -70
  236. package/src/cds/nlp/autograd/_grad.py +0 -120
  237. package/src/cds/nlp/autograd/ops.py +0 -133
  238. package/src/cds/nlp/autograd/tensor.py +0 -298
  239. package/src/cds/nlp/bpe.py +0 -449
  240. package/src/cds/nlp/data.py +0 -70
  241. package/src/cds/nlp/embed.py +0 -190
  242. package/src/cds/nlp/layers.py +0 -259
  243. package/src/cds/nlp/model.py +0 -456
  244. package/src/cds/nlp/optim.py +0 -163
  245. package/src/cds/nlp/training.py +0 -167
  246. package/src/cds/nlp/viz.py +0 -254
  247. package/src/cds/numerical_integration/__init__.py +0 -31
  248. package/src/cds/numerical_integration/quadrature.py +0 -480
  249. package/src/cds/optimization/__init__.py +0 -26
  250. package/src/cds/optimization/_metaheuristics.py +0 -287
  251. package/src/cds/optimization/constrained.py +0 -212
  252. package/src/cds/optimization/minimize.py +0 -425
  253. package/src/cds/pde/__init__.py +0 -266
  254. package/src/cds/plot/__init__.py +0 -49
  255. package/src/cds/plot/_backend.py +0 -32
  256. package/src/cds/plot/charts.py +0 -462
  257. package/src/cds/probability/__init__.py +0 -65
  258. package/src/cds/probability/_advanced.py +0 -283
  259. package/src/cds/probability/distributions.py +0 -236
  260. package/src/cds/probability/extra_distributions.py +0 -199
  261. package/src/cds/provenance/__init__.py +0 -25
  262. package/src/cds/provenance/manifest.py +0 -355
  263. package/src/cds/py.typed +0 -0
  264. package/src/cds/quantum/__init__.py +0 -51
  265. package/src/cds/quantum/circuit.py +0 -122
  266. package/src/cds/quantum/multi_qubit.py +0 -310
  267. package/src/cds/quantum/simulator.py +0 -53
  268. package/src/cds/scientific/__init__.py +0 -34
  269. package/src/cds/scientific/constants.py +0 -35
  270. package/src/cds/scientific/formulas.py +0 -116
  271. package/src/cds/sensitivity.py +0 -204
  272. package/src/cds/signals/__init__.py +0 -59
  273. package/src/cds/signals/filters.py +0 -449
  274. package/src/cds/signals/processing.py +0 -224
  275. package/src/cds/signals/stft.py +0 -177
  276. package/src/cds/signals/wavelet.py +0 -146
  277. package/src/cds/stats/__init__.py +0 -99
  278. package/src/cds/stats/_distributions.py +0 -102
  279. package/src/cds/stats/bootstrap.py +0 -188
  280. package/src/cds/stats/descriptive.py +0 -172
  281. package/src/cds/stats/hypothesis_tests.py +0 -294
  282. package/src/cds/stats/nonparametric.py +0 -141
  283. package/src/cds/stats/power.py +0 -290
  284. package/src/cds/stats/regression.py +0 -51
  285. package/src/cds/stats/time_series.py +0 -420
  286. package/src/cds/tools/__init__.py +0 -29
  287. package/src/cds/tools/adapters.py +0 -218
  288. package/src/cds/tools/registry.py +0 -181
  289. package/src/cds/uncertainty/__init__.py +0 -17
  290. package/src/cds/uncertainty/propagation.py +0 -233
  291. package/src/cds/units/__init__.py +0 -45
  292. package/src/cds/units/core.py +0 -199
  293. package/src/cds/validation/__init__.py +0 -41
  294. package/src/cds/validation/adequacy.py +0 -157
  295. package/src/cds/validation/checks.py +0 -485
  296. package/src/cds/validation/report.py +0 -50
  297. package/src/cds/wavelets/__init__.py +0 -5
  298. package/src/cds/wavelets/haar.py +0 -219
  299. package/src/cds/workflow/__init__.py +0 -77
  300. package/src/cds/workflow/engine.py +0 -116
  301. package/src/cds/workflow/gates.py +0 -120
  302. package/src/cds/workflow/orchestrator.py +0 -431
  303. package/src/cds/workflow/selection.py +0 -454
  304. package/src/cds/workflow/tooling.py +0 -155
  305. package/src/cds/workflow/types.py +0 -107
  306. package/tests/__init__.py +0 -0
  307. package/tests/conftest.py +0 -109
  308. package/tests/test_advanced_fitting.py +0 -247
  309. package/tests/test_audit_completion_coverage.py +0 -183
  310. package/tests/test_audit_guard_coverage.py +0 -115
  311. package/tests/test_audit_hardening.py +0 -138
  312. package/tests/test_audit_hardening_coverage.py +0 -111
  313. package/tests/test_bayes_v2.py +0 -208
  314. package/tests/test_benchmarks.py +0 -111
  315. package/tests/test_bootstrap.py +0 -135
  316. package/tests/test_cli.py +0 -51
  317. package/tests/test_cli_color.py +0 -114
  318. package/tests/test_cli_extended.py +0 -239
  319. package/tests/test_cli_system_info.py +0 -36
  320. package/tests/test_constrained_opt.py +0 -174
  321. package/tests/test_core.py +0 -273
  322. package/tests/test_data_analysis.py +0 -146
  323. package/tests/test_data_analysis_lazy_bridge.py +0 -68
  324. package/tests/test_data_analysis_pandas_io.py +0 -119
  325. package/tests/test_data_io.py +0 -149
  326. package/tests/test_dataset.py +0 -91
  327. package/tests/test_diffeq.py +0 -186
  328. package/tests/test_diffeq_implicit.py +0 -173
  329. package/tests/test_domain_validation.py +0 -66
  330. package/tests/test_edge_misc_numerical.py +0 -666
  331. package/tests/test_edge_ml_quantum_linalg.py +0 -191
  332. package/tests/test_edge_nlp.py +0 -229
  333. package/tests/test_edge_quantum_evaluator_cli.py +0 -601
  334. package/tests/test_edge_stats_optimization_signals.py +0 -406
  335. package/tests/test_extra_distributions.py +0 -206
  336. package/tests/test_fft2.py +0 -67
  337. package/tests/test_fitting_bootstrap.py +0 -202
  338. package/tests/test_fractals.py +0 -387
  339. package/tests/test_genetics.py +0 -159
  340. package/tests/test_graph.py +0 -380
  341. package/tests/test_hardening_privacy_provenance.py +0 -306
  342. package/tests/test_hypothesis.py +0 -216
  343. package/tests/test_hypothesis_engine.py +0 -59
  344. package/tests/test_hypothesis_mining.py +0 -247
  345. package/tests/test_hypothesis_tests.py +0 -277
  346. package/tests/test_infotheory.py +0 -302
  347. package/tests/test_interpolate.py +0 -189
  348. package/tests/test_knowledge.py +0 -1149
  349. package/tests/test_layering.py +0 -112
  350. package/tests/test_linalg_extended.py +0 -179
  351. package/tests/test_linalg_qr_cholesky.py +0 -68
  352. package/tests/test_markov.py +0 -155
  353. package/tests/test_math_utils.py +0 -157
  354. package/tests/test_ml_boosting.py +0 -148
  355. package/tests/test_ml_clustering.py +0 -92
  356. package/tests/test_ml_ensemble.py +0 -103
  357. package/tests/test_ml_knn.py +0 -95
  358. package/tests/test_ml_linreg.py +0 -70
  359. package/tests/test_ml_logreg.py +0 -84
  360. package/tests/test_ml_metrics.py +0 -125
  361. package/tests/test_ml_model_selection.py +0 -108
  362. package/tests/test_ml_naive_bayes.py +0 -183
  363. package/tests/test_ml_pca.py +0 -98
  364. package/tests/test_ml_preprocessing.py +0 -104
  365. package/tests/test_ml_tree.py +0 -89
  366. package/tests/test_ml_viz.py +0 -58
  367. package/tests/test_ml_voting.py +0 -219
  368. package/tests/test_modeling.py +0 -726
  369. package/tests/test_modeling_fit_validation.py +0 -46
  370. package/tests/test_montecarlo.py +0 -245
  371. package/tests/test_multi_qubit.py +0 -466
  372. package/tests/test_nlp_attention.py +0 -335
  373. package/tests/test_nlp_autograd.py +0 -435
  374. package/tests/test_nlp_bpe.py +0 -463
  375. package/tests/test_nlp_embed.py +0 -240
  376. package/tests/test_nlp_layers.py +0 -276
  377. package/tests/test_nlp_model.py +0 -172
  378. package/tests/test_nlp_training.py +0 -262
  379. package/tests/test_nlp_viz.py +0 -188
  380. package/tests/test_numerical_integration.py +0 -374
  381. package/tests/test_numerical_invariants.py +0 -768
  382. package/tests/test_numerical_oracles.py +0 -241
  383. package/tests/test_optimization.py +0 -139
  384. package/tests/test_optimization_metaheuristics.py +0 -221
  385. package/tests/test_pde.py +0 -294
  386. package/tests/test_plot_charts.py +0 -247
  387. package/tests/test_plot_lazy.py +0 -48
  388. package/tests/test_power.py +0 -226
  389. package/tests/test_probability.py +0 -274
  390. package/tests/test_probability_advanced.py +0 -226
  391. package/tests/test_property_invariants.py +0 -277
  392. package/tests/test_provenance.py +0 -215
  393. package/tests/test_provenance_audit_hardening.py +0 -45
  394. package/tests/test_public_api.py +0 -75
  395. package/tests/test_quantum.py +0 -195
  396. package/tests/test_release_contract.py +0 -105
  397. package/tests/test_retrieval.py +0 -255
  398. package/tests/test_scientific.py +0 -185
  399. package/tests/test_selection_audit_hardening.py +0 -55
  400. package/tests/test_sensitivity.py +0 -59
  401. package/tests/test_sensitivity_global.py +0 -73
  402. package/tests/test_signals.py +0 -146
  403. package/tests/test_signals_filters.py +0 -460
  404. package/tests/test_special_invariants.py +0 -222
  405. package/tests/test_special_numerics.py +0 -44
  406. package/tests/test_statistical_audit.py +0 -75
  407. package/tests/test_stats.py +0 -206
  408. package/tests/test_stats_audit_coverage.py +0 -17
  409. package/tests/test_stats_nonparametric.py +0 -87
  410. package/tests/test_stats_time_series.py +0 -352
  411. package/tests/test_stft.py +0 -208
  412. package/tests/test_streaming_analytics.py +0 -128
  413. package/tests/test_svd.py +0 -170
  414. package/tests/test_symplectic.py +0 -200
  415. package/tests/test_tool_adapters.py +0 -197
  416. package/tests/test_tools_registry.py +0 -132
  417. package/tests/test_uncertainty.py +0 -171
  418. package/tests/test_units.py +0 -139
  419. package/tests/test_validation.py +0 -100
  420. package/tests/test_validation_adequacy.py +0 -129
  421. package/tests/test_validation_advanced.py +0 -110
  422. package/tests/test_wavelet.py +0 -170
  423. package/tests/test_wavelets_v2.py +0 -119
  424. package/tests/test_workflow.py +0 -173
  425. package/tests/test_workflow_gates.py +0 -144
  426. package/tests/test_workflow_orchestrator.py +0 -516
  427. package/tests/test_workflow_orchestrator_blocked_review.py +0 -95
  428. package/tests/test_workflow_selection.py +0 -312
  429. package/tests/test_workflow_selection_coverage.py +0 -114
  430. package/tests/test_workflow_tooling.py +0 -190
@@ -1,124 +0,0 @@
1
- """
2
- Demo: end-to-end PCA with preprocessing — scaling, variance analysis,
3
- 2-D projection, reconstruction, and train/test discipline.
4
- Everything is 100% Pure Python.
5
- """
6
-
7
- import random
8
-
9
- from cds.data_analysis import plot_bar
10
- from cds.ml import PCA, PCAResult, StandardScaler, train_test_split
11
-
12
- SEED = 42
13
- FEATURE_NAMES = ["sensor_mm", "load_kg", "temp_diff", "noise", "bias_const"]
14
-
15
-
16
- def make_dataset(n_per_cluster: int = 80) -> tuple[list[list[float]], list[float]]:
17
- """Two latent clusters embedded in 5 features with deliberate pitfalls.
18
-
19
- - sensor_mm is measured in millimeters (huge scale vs the rest)
20
- - noise is pure random information
21
- - bias_const is a zero-variance column
22
- """
23
- rng = random.Random(SEED)
24
- X: list[list[float]] = []
25
- y: list[float] = []
26
- for cluster in (0, 1):
27
- center = -1.0 if cluster == 0 else 1.0
28
- for _ in range(n_per_cluster):
29
- latent = center + rng.gauss(0.0, 0.8)
30
- row = [
31
- 1000.0 * (latent + 0.3 * rng.gauss(0.0, 1.0)),
32
- 1.5 * latent + 0.3 * rng.gauss(0.0, 1.0),
33
- -latent + 0.3 * rng.gauss(0.0, 1.0),
34
- rng.gauss(0.0, 1.0),
35
- 7.0,
36
- ]
37
- X.append(row)
38
- y.append(float(cluster))
39
- return X, y
40
-
41
-
42
- def ascii_scatter(points: list[list[float]], labels: list[float]) -> str:
43
- """Bin 2-D points into a character grid: cluster 0 -> 'A', 1 -> 'B'."""
44
- width, height = 56, 16
45
- xs = [p[0] for p in points]
46
- ys = [p[1] for p in points]
47
- x_min, x_max = min(xs), max(xs)
48
- y_min, y_max = min(ys), max(ys)
49
- x_span = (x_max - x_min) or 1.0
50
- y_span = (y_max - y_min) or 1.0
51
- grid = [[" "] * width for _ in range(height)]
52
- for (px, py), label in zip(points, labels):
53
- col = int((px - x_min) / x_span * (width - 1))
54
- row = height - 1 - int((py - y_min) / y_span * (height - 1))
55
- mark = "A" if label == 0 else "B"
56
- if grid[row][col] != " ":
57
- mark = "#"
58
- grid[row][col] = mark
59
- return "\n".join("".join(r) for r in grid)
60
-
61
-
62
- def explained_variance_report(model: PCAResult, prefix: str) -> None:
63
- ratios = model.explained_variance_ratio_
64
- bars = {f"PC{i + 1}": round(r, 4) for i, r in enumerate(ratios)}
65
- print(plot_bar(bars, title=f"{prefix}: explained variance ratio"))
66
- cumulative = 0.0
67
- for i, r in enumerate(ratios):
68
- cumulative += r
69
- print(f" PC{i + 1}: {r:7.4f} cumulative {cumulative:7.4f}")
70
- k90 = next(i + 1 for i, _ in enumerate(ratios) if sum(ratios[: i + 1]) >= 0.90)
71
- print(f" -> {k90} component(s) capture >= 90% of the variance")
72
-
73
-
74
- def mean_abs_error(original: list[list[float]], reconstructed: list[list[float]]) -> float:
75
- diffs = [
76
- abs(original[i][d] - reconstructed[i][d])
77
- for i in range(len(original))
78
- for d in range(len(original[i]))
79
- ]
80
- return sum(diffs) / len(diffs)
81
-
82
-
83
- def run_demo() -> None:
84
- X, y = make_dataset()
85
- n_samples, n_features = len(X), len(X[0])
86
- print("--- End-to-End PCA + Preprocessing Demo ---")
87
- print(f"Dataset: {n_samples} samples x {n_features} features, two hidden clusters")
88
- print(f"Features: {', '.join(FEATURE_NAMES)}")
89
-
90
- print("\n[1] Why scaling matters — PCA on RAW data")
91
- raw_model = PCA(n_components=n_features).fit(X)
92
- explained_variance_report(raw_model, "RAW")
93
- print(" The millimeter-scale column dominates; cluster structure is invisible.")
94
-
95
- print("\n[2] StandardScaler -> PCA on SCALED data")
96
- scaler = StandardScaler().fit(X)
97
- Xs = scaler.transform(X)
98
- scaled_model = PCA(n_components=n_features).fit(Xs)
99
- explained_variance_report(scaled_model, "SCALED")
100
- print(" Zero-variance 'bias_const' became a flat 0 column and contributes nothing.")
101
-
102
- print("\n[3] Project onto the top 2 components")
103
- model2 = PCA(n_components=2).fit(Xs)
104
- Z = model2.transform(Xs)
105
- print(ascii_scatter(Z, y))
106
- print(" A/B = true clusters — PC1 alone separates them.")
107
-
108
- print("\n[4] Round-trip: 2-D projection -> inverse_transform")
109
- X_rec = model2.inverse_transform(Z)
110
- print(f" mean |x - reconstruct(x)| on scaled data: {mean_abs_error(Xs, X_rec):.4f}")
111
-
112
- print("\n[5] Train/test discipline — fit on train only, then transform test")
113
- X_train, X_test, _, _ = train_test_split(X, y, test_size=0.25, seed=SEED)
114
- scaler_t = StandardScaler().fit(X_train)
115
- pca_t = PCA(n_components=2).fit(scaler_t.transform(X_train))
116
- Z_test = pca_t.transform(scaler_t.transform(X_test))
117
- X_test_rec = pca_t.inverse_transform(Z_test)
118
- test_err = mean_abs_error(scaler_t.transform(X_test), X_test_rec)
119
- print(f" test samples: {len(X_test)}, reconstruction error: {test_err:.4f}")
120
- print(" No statistics leak from the test set into the fitted pipeline.")
121
-
122
-
123
- if __name__ == "__main__":
124
- run_demo()
@@ -1,65 +0,0 @@
1
- """PDE solver demo — heat diffusion of a Gaussian blob and a plucked string."""
2
-
3
- import math
4
-
5
- from cds.pde import solve_heat, solve_wave
6
-
7
-
8
- def main() -> None:
9
- # --- Heat equation: Gaussian blob ---
10
- print("=== Heat equation: Gaussian blob (alpha=0.01) ===")
11
- nx = 101
12
- length = 1.0
13
- alpha = 0.01
14
-
15
- def blob(x: float) -> float:
16
- return math.exp(-(((x - 0.5) / 0.08) ** 2))
17
-
18
- u0 = [blob(length * i / (nx - 1)) for i in range(nx)]
19
- dx = length / (nx - 1)
20
-
21
- hot = solve_heat(u0, alpha, length, t_final=0.4, nx=nx, boundary="dirichlet")
22
- print(f"Dirichlet ends: auto dt={hot.dt:.6f} ({hot.n_steps} steps)")
23
- print(f" peak temperature: {max(u0):.6f} -> {max(hot.u_final):.6f}")
24
-
25
- insulated = solve_heat(u0, alpha, length, t_final=0.4, nx=nx, boundary="neumann")
26
- mass0 = sum(u0) * dx
27
- mass1 = sum(insulated.u_final) * dx
28
- drift = abs(mass1 - mass0) / mass0
29
- print(f"Neumann ends : auto dt={insulated.dt:.6f} ({insulated.n_steps} steps)")
30
- print(f" total heat mass: {mass0:.6f} -> {mass1:.6f} (relative drift {drift:.2e})")
31
-
32
- # --- Wave equation: plucked string ---
33
- print("\n=== Wave equation: plucked string (c=1.0) ===")
34
- nx_w = 81
35
- c = 1.0
36
- xs_w = [length * i / (nx_w - 1) for i in range(nx_w)]
37
- center = length / 2.0
38
- pluck = 0.2
39
-
40
- def triangle(x: float) -> float:
41
- if x <= center:
42
- return 2.0 * pluck * x / length
43
- return 2.0 * pluck * (1.0 - x / length)
44
-
45
- u0_w = [triangle(x) for x in xs_w]
46
- v0_w = [0.0] * nx_w
47
- t_final_w = 0.8
48
- string = solve_wave(u0_w, v0_w, c, length, t_final=t_final_w, nx=nx_w)
49
- courant = c * string.dt / (length / (nx_w - 1))
50
- print(
51
- f"Auto dt={string.dt:.6f} chosen by CFL safety rule "
52
- f"(Courant number C = {courant:.3f}, {string.n_steps} steps)"
53
- )
54
- peak0 = max(abs(u) for u in u0_w)
55
- peak1 = max(abs(u) for u in string.u_final)
56
- print(f"Peak |displacement| at t={t_final_w}: {peak0:.4f} -> {peak1:.4f}")
57
- print(f"Reflected wave inverted the profile (final min = {min(string.u_final):+.4f})")
58
- print(
59
- f"String still pinned at both ends: "
60
- f"{abs(string.u_final[0]) < 1e-12 and abs(string.u_final[-1]) < 1e-12}"
61
- )
62
-
63
-
64
- if __name__ == "__main__":
65
- main()
@@ -1,84 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Demo: optional ``cds[plot]`` matplotlib helpers.
3
-
4
- Requires: ``pip install scientific-computing-system[plot]``
5
-
6
- Saves figures under ``examples/_plot_out/``.
7
- """
8
-
9
- from __future__ import annotations
10
-
11
- import math
12
- from pathlib import Path
13
-
14
- from cds.plot import (
15
- plot_acf,
16
- plot_heatmap,
17
- plot_histogram,
18
- plot_loss,
19
- plot_multi_series,
20
- plot_optimization_path,
21
- plot_power_spectrum,
22
- plot_regression,
23
- plot_scatter,
24
- plot_seasonal_decompose,
25
- plot_series,
26
- plot_waveform,
27
- save_figure,
28
- )
29
-
30
-
31
- def main() -> None:
32
- out = Path(__file__).resolve().parent / "_plot_out"
33
- out.mkdir(exist_ok=True)
34
-
35
- y = [math.sin(2 * math.pi * i / 40) + 0.1 * math.sin(2 * math.pi * i / 7) for i in range(120)]
36
- save_figure(plot_series(y, title="Noisy sine"), str(out / "series.png"))
37
- save_figure(plot_histogram(y, bins=24, title="Amplitude histogram"), str(out / "hist.png"))
38
- save_figure(
39
- plot_multi_series(
40
- {
41
- "raw": y,
42
- "abs": [abs(v) for v in y],
43
- },
44
- title="Multi-series",
45
- ),
46
- str(out / "multi.png"),
47
- )
48
-
49
- n, fs = 128, 128.0
50
- signal = [math.sin(2 * math.pi * 8 * t / fs) for t in range(n)]
51
- save_figure(plot_waveform(signal, sample_rate=fs, title="8 Hz tone"), str(out / "wave.png"))
52
- save_figure(
53
- plot_power_spectrum(signal, sample_rate=fs, title="Power spectrum"),
54
- str(out / "power.png"),
55
- )
56
-
57
- ar = [0.0]
58
- for i in range(1, 100):
59
- ar.append(0.75 * ar[-1] + (0.2 if i % 3 == 0 else -0.05))
60
- save_figure(plot_acf(ar, max_lag=20, title="ACF"), str(out / "acf.png"))
61
-
62
- seasonal = [1.0, 2.0, 3.0, 2.0, 1.0, 0.5] * 5
63
- save_figure(
64
- plot_seasonal_decompose(seasonal, period=6, title="Seasonal"),
65
- str(out / "seasonal.png"),
66
- )
67
-
68
- xs = [float(i) for i in range(1, 11)]
69
- ys = [2.0 * x + 1.0 + (0.3 if i % 2 else -0.2) for i, x in enumerate(xs)]
70
- save_figure(plot_scatter(xs, ys, title="Scatter"), str(out / "scatter.png"))
71
- save_figure(plot_regression(xs, ys, title="OLS fit"), str(out / "regression.png"))
72
-
73
- mat = [[math.sin((i + 1) * (j + 1) / 5) for j in range(8)] for i in range(6)]
74
- save_figure(plot_heatmap(mat, title="Heatmap"), str(out / "heatmap.png"))
75
-
76
- save_figure(plot_loss([1.0 / (i + 1) for i in range(40)], title="Loss"), str(out / "loss.png"))
77
- path = [(math.cos(t / 8) * (1 - t / 40), math.sin(t / 8) * (1 - t / 40)) for t in range(40)]
78
- save_figure(plot_optimization_path(path, title="Spiral"), str(out / "opt_path.png"))
79
-
80
- print(f"Wrote figures to {out}")
81
-
82
-
83
- if __name__ == "__main__":
84
- main()
@@ -1,87 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "markdown",
5
- "id": "7fb27b941602401d91542211134fc71a",
6
- "metadata": {},
7
- "source": [
8
- "# CDS plotting notebook\n",
9
- "\n",
10
- "Requires `pip install scientific-computing-system[plot]`.\n",
11
- "Companion to `examples/plot_demo.py` and the Cookbook matplotlib section.\n"
12
- ]
13
- },
14
- {
15
- "cell_type": "code",
16
- "execution_count": null,
17
- "id": "acae54e37e7d407bbb7b55eff062a284",
18
- "metadata": {},
19
- "outputs": [],
20
- "source": [
21
- "import math\n",
22
- "\n",
23
- "from cds.plot import plot_acf, plot_series, plot_spectrum, plot_waveform\n",
24
- "from cds.signals import power_spectrum"
25
- ]
26
- },
27
- {
28
- "cell_type": "code",
29
- "execution_count": null,
30
- "id": "9a63283cbaf04dbcab1f6479b197f3a8",
31
- "metadata": {},
32
- "outputs": [],
33
- "source": [
34
- "y = [math.sin(2 * math.pi * i / 40) for i in range(100)]\n",
35
- "fig = plot_series(y, title=\"Sine wave\")\n",
36
- "fig"
37
- ]
38
- },
39
- {
40
- "cell_type": "code",
41
- "execution_count": null,
42
- "id": "8dd0d8092fe74a7c96281538738b07e2",
43
- "metadata": {},
44
- "outputs": [],
45
- "source": [
46
- "n, fs = 128, 128.0\n",
47
- "signal = [math.sin(2 * math.pi * 8 * t / fs) for t in range(n)]\n",
48
- "plot_waveform(signal, sample_rate=fs, title=\"8 Hz tone\")"
49
- ]
50
- },
51
- {
52
- "cell_type": "code",
53
- "execution_count": null,
54
- "id": "72eea5119410473aa328ad9291626812",
55
- "metadata": {},
56
- "outputs": [],
57
- "source": [
58
- "power = power_spectrum(signal)\n",
59
- "half = [math.sqrt(max(0.0, p)) for p in power[: n // 2]]\n",
60
- "plot_spectrum(half, sample_rate=fs / 2, title=\"Spectrum\")"
61
- ]
62
- },
63
- {
64
- "cell_type": "code",
65
- "execution_count": null,
66
- "id": "8edb47106e1a46a883d545849b8ab81b",
67
- "metadata": {},
68
- "outputs": [],
69
- "source": [
70
- "plot_acf(y, max_lag=20, title=\"ACF\")"
71
- ]
72
- }
73
- ],
74
- "metadata": {
75
- "kernelspec": {
76
- "display_name": "Python 3",
77
- "language": "python",
78
- "name": "python3"
79
- },
80
- "language_info": {
81
- "name": "python",
82
- "pygments_lexer": "ipython3"
83
- }
84
- },
85
- "nbformat": 4,
86
- "nbformat_minor": 5
87
- }
@@ -1,39 +0,0 @@
1
- """Probability distributions and sampling demo."""
2
-
3
- import math
4
-
5
- from cds.probability import (
6
- binomial_pmf,
7
- exponential_pdf,
8
- gaussian_pdf,
9
- poisson_pmf,
10
- uniform_pdf,
11
- uniform_sample,
12
- )
13
-
14
-
15
- def main() -> None:
16
- print("=== Continuous PDFs ===")
17
- peak = gaussian_pdf(0.0, mu=0.0, sigma=1.0)
18
- print(f"gaussian_pdf(0; mu=0, sigma=1) = {peak:.6f}")
19
- print(f" (1/sqrt(2π) ≈ {1.0 / math.sqrt(2 * math.pi):.6f})")
20
- print(f"uniform_pdf(0.5; a=0, b=1) = {uniform_pdf(0.5, a=0.0, b=1.0):.6f} (expect 1)")
21
- print(f"exponential_pdf(1; lam=2) = {exponential_pdf(1.0, lam=2.0):.6f}")
22
-
23
- print("\n=== Discrete PMFs ===")
24
- print("Binomial PMF (n=10, p=0.5):")
25
- for k in range(0, 11):
26
- print(f" P(X={k}) = {binomial_pmf(k, n=10, p=0.5):.4f}")
27
- print("Poisson PMF (lam=3):")
28
- for k in range(0, 6):
29
- print(f" P(X={k}) = {poisson_pmf(k, lam=3.0):.4f}")
30
-
31
- print("\n=== Sampling ===")
32
- samples = uniform_sample(a=0.0, b=1.0, n=5, seed=42)
33
- print(f"5 samples from Uniform(0,1), seed=42: {samples}")
34
- mean = sum(samples) / len(samples)
35
- print(f"sample mean = {mean:.4f}")
36
-
37
-
38
- if __name__ == "__main__":
39
- main()
@@ -1,42 +0,0 @@
1
- """Quantum computing demo — Bell states and entanglement."""
2
-
3
- from cds.quantum import (
4
- QuantumCircuit,
5
- bell_state,
6
- ghz_state,
7
- hadamard,
8
- is_entangled,
9
- simulate,
10
- )
11
-
12
- # --- Single-qubit circuit ---
13
-
14
-
15
- def main() -> None:
16
- print("=== Single-Qubit Circuit ===")
17
- circuit = QuantumCircuit().add(hadamard())
18
- result = circuit.run()
19
- print(f"After Hadamard: P(0)={result.probabilities()[0]:.3f}")
20
-
21
- counts = simulate(circuit, shots=10000)
22
- print(f"Measurement (10k shots): {counts}\n")
23
-
24
- # --- Bell state ---
25
- print("=== Bell State |Φ+⟩ ===")
26
- phi_plus = bell_state(0)
27
- print(f"Entangled? {is_entangled(phi_plus)}")
28
- bell_counts = phi_plus.measure_shots(shots=10000, seed=42)
29
- print(f"Measurements: {bell_counts}\n")
30
-
31
- # --- GHZ state ---
32
- print("=== 4-Qubit GHZ State ===")
33
- ghz = ghz_state(4)
34
- probs = ghz.probabilities()
35
- print(f"P(|0000⟩) = {probs[0]:.3f}")
36
- print(f"P(|1111⟩) = {probs[15]:.3f}")
37
- ghz_counts = ghz.measure_shots(shots=10000, seed=7)
38
- print(f"Measurements: {ghz_counts}")
39
-
40
-
41
- if __name__ == "__main__":
42
- main()
@@ -1,49 +0,0 @@
1
- """Scientific constants and physics formulas demo."""
2
-
3
- from cds.scientific import (
4
- CONSTANTS,
5
- de_broglie_wavelength,
6
- escape_velocity,
7
- get_constant,
8
- gravitational_force,
9
- ideal_gas_pressure,
10
- kinetic_energy,
11
- photon_energy,
12
- schwarzschild_radius,
13
- wave_frequency,
14
- )
15
-
16
-
17
- def main() -> None:
18
- print("=== Physical Constants ===")
19
- c = get_constant("c")
20
- G = get_constant("G")
21
- print(f"Speed of light c = {c} m/s")
22
- print(f"Gravitational constant G = {G} N·m²/kg²")
23
- print(f"Available constants: {sorted(CONSTANTS)}")
24
-
25
- print("\n=== Mechanics ===")
26
- ke = kinetic_energy(mass=10.0, velocity=5.0)
27
- fg = gravitational_force(m1=5.0, m2=10.0, r=2.0)
28
- ev = escape_velocity(mass=5.972e24, radius=6.371e6)
29
- print(f"Kinetic energy (10kg @ 5m/s) = {ke:.2f} J")
30
- print(f"Gravitational force (5kg,10kg @ 2m) = {fg:.6e} N")
31
- print(f"Earth escape velocity = {ev:.1f} m/s")
32
-
33
- print("\n=== Waves & Photons ===")
34
- pe = photon_energy(frequency=5.0e14)
35
- wf = wave_frequency(wavelength=500e-9)
36
- dbw = de_broglie_wavelength(mass=9.109e-31, velocity=1.0e6)
37
- print(f"Photon energy @ 5e14 Hz = {pe:.4e} J")
38
- print(f"Frequency of 500nm light = {wf:.4e} Hz")
39
- print(f"de Broglie wavelength (electron @ 1e6 m/s) = {dbw:.4e} m")
40
-
41
- print("\n=== Astrophysics & Thermo ===")
42
- rs = schwarzschild_radius(mass=1.989e30)
43
- pg = ideal_gas_pressure(n_moles=1.0, temperature=300.0, volume=0.024)
44
- print(f"Sun Schwarzschild radius = {rs:.2f} m")
45
- print(f"Ideal gas pressure (n=1,T=300,V=0.024) = {pg:.2f} Pa")
46
-
47
-
48
- if __name__ == "__main__":
49
- main()
@@ -1,86 +0,0 @@
1
- """Signal processing demo — FFT and filtering."""
2
-
3
- import math
4
-
5
- from cds.signals import (
6
- apply_filter,
7
- butter_bandpass,
8
- butter_lowpass,
9
- convolve,
10
- dft,
11
- fft_radix2,
12
- low_pass_filter,
13
- moving_median,
14
- )
15
-
16
- # --- DFT of a simple signal ---
17
-
18
-
19
- def main() -> None:
20
- print("=== DFT of Cosine Signal ===")
21
- n = 16
22
- signal = [complex(math.cos(2 * math.pi * 2 * k / n)) for k in range(n)]
23
- spectrum = dft(signal)
24
- print("Frequency magnitudes:")
25
- for k, x in enumerate(spectrum):
26
- mag = abs(x)
27
- if mag > 0.5:
28
- print(f" Bin {k}: {mag:.2f}")
29
-
30
- # --- FFT comparison ---
31
- print("\n=== FFT (radix-2) ===")
32
- fft_result = fft_radix2(signal)
33
- print(f"FFT matches DFT: {all(abs(a - b) < 1e-9 for a, b in zip(spectrum, fft_result))}")
34
-
35
- # --- Convolution ---
36
- print("\n=== Convolution ===")
37
- a = [1.0, 2.0, 3.0, 4.0]
38
- b = [0.5, 0.5] # averaging kernel
39
- result = convolve(a, b)
40
- print(f"{a} * {b} = {[round(x, 1) for x in result]}")
41
-
42
- # --- Low-pass filter ---
43
- print("\n=== Low-Pass Filter ===")
44
- noisy = [1 + 0.3 * math.sin(2 * math.pi * 7 * k / n) for k in range(n)]
45
- filtered = low_pass_filter([complex(x) for x in noisy], cutoff=3)
46
- print("Original (first 8):", [f"{x:.2f}" for x in noisy[:8]])
47
- print("Filtered (first 8):", [f"{x.real:.2f}" for x in filtered[:8]])
48
-
49
- # --- Butterworth IIR low-pass ---
50
- print("\n=== Butterworth Low-Pass (IIR) ===")
51
- m = 512
52
- # slow trend at 2% of Nyquist (well inside the passband), fast jitter at 90%.
53
- clean = [math.sin(math.pi * 0.02 * k) for k in range(m)]
54
- jitter = [0.5 * math.sin(math.pi * 0.9 * k) for k in range(m)]
55
- mixed = [a + c for a, c in zip(clean, jitter)]
56
-
57
- coef = butter_lowpass(order=4, cutoff=0.2)
58
- smoothed = apply_filter(mixed, coef)
59
- tail = slice(m // 2, m)
60
- in_amp = (max(mixed[tail]) - min(mixed[tail])) / 2
61
- out_amp = (max(smoothed[tail]) - min(smoothed[tail])) / 2
62
- print(f"input amplitude : {in_amp:.3f} (trend + near-Nyquist jitter)")
63
- print(f"output amplitude: {out_amp:.3f} (~1.0: jitter gone, trend kept)")
64
-
65
- # --- Band-pass isolate a single tone ---
66
- print("\n=== Band-Pass Isolation ===")
67
- tones = [math.sin(math.pi * w * k) for w, k in zip([0.1] * m, range(m))]
68
- for k in range(m): # add a second in-band tone plus an out-of-band one
69
- tones[k] += 0.8 * math.sin(math.pi * 0.35 * k)
70
- tones[k] += 0.6 * math.sin(math.pi * 0.8 * k)
71
- bp = butter_bandpass(order=4, low=0.2, high=0.5)
72
- isolated = apply_filter(tones, bp)
73
- iso_amp = (max(isolated[tail]) - min(isolated[tail])) / 2
74
- print(f"band-pass amplitude (0.35 tone): {iso_amp:.3f} (~0.8 expected)")
75
-
76
- # --- Moving-median spike removal ---
77
- print("\n=== Moving-Median Denoising ===")
78
- base = [1.0] * 8
79
- spiked = base[:3] + [25.0] + base[3:6] + [-18.0] + base[6:]
80
- restored = moving_median(spiked, window=3)
81
- print(f"input : {[round(x, 1) for x in spiked]}")
82
- print(f"denoised: {[round(x, 1) for x in restored]}")
83
-
84
-
85
- if __name__ == "__main__":
86
- main()
@@ -1,40 +0,0 @@
1
- """Statistics and regression demo."""
2
-
3
- from cds.stats import (
4
- correlation,
5
- linear_regression,
6
- mean,
7
- median,
8
- stdev,
9
- variance,
10
- )
11
-
12
- # --- Descriptive statistics ---
13
-
14
-
15
- def main() -> None:
16
- data = [23.1, 27.5, 19.8, 31.2, 25.6, 28.3, 22.0, 30.1]
17
- print("=== Descriptive Statistics ===")
18
- print(f"Data: {data}")
19
- print(f"Mean: {mean(data):.2f}")
20
- print(f"Median: {median(data):.2f}")
21
- print(f"Variance: {variance(data):.2f}")
22
- print(f"Std Dev: {stdev(data):.2f}")
23
-
24
- # --- Correlation ---
25
- print("\n=== Correlation ===")
26
- x = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]
27
- y = [2.1, 4.3, 5.8, 8.1, 9.7, 12.2, 13.8, 16.1]
28
- r = correlation(x, y)
29
- print(f"r = {r:.4f} (1.0 = perfect positive)")
30
-
31
- # --- Linear regression ---
32
- print("\n=== Linear Regression ===")
33
- reg = linear_regression(x, y)
34
- print(f"y = {reg.slope:.2f}x + {reg.intercept:.2f}")
35
- print(f"R² = {reg.r_squared:.4f}")
36
- print(f"Prediction at x=10: {reg.predict(10):.2f}")
37
-
38
-
39
- if __name__ == "__main__":
40
- main()