{"id":15798077,"url":"https://github.com/qequ/pyrite","last_synced_at":"2025-10-28T07:36:22.394Z","repository":{"id":215837812,"uuid":"738730774","full_name":"qequ/pyrite","owner":"qequ","description":"A Crystal library for scientific computing - featuring complex numbers, PRNGs, root-finding, statistical distributions, and more. Inspired by SciLua.","archived":false,"fork":false,"pushed_at":"2024-01-06T20:29:17.000Z","size":274,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-12T00:48:55.635Z","etag":null,"topics":["complex-numbers","crystal-lang","mathematics","numerical-methods","prng","root-finding","scientific-computing","statistics"],"latest_commit_sha":null,"homepage":"","language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qequ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2024-01-03T23:07:26.000Z","updated_at":"2024-02-28T23:20:43.000Z","dependencies_parsed_at":"2024-01-14T08:58:58.487Z","dependency_job_id":null,"html_url":"https://github.com/qequ/pyrite","commit_stats":{"total_commits":26,"total_committers":1,"mean_commits":26.0,"dds":0.0,"last_synced_commit":"666244fcd66019620ed2c29b4b20d47161284c68"},"previous_names":["qequ/pyrite"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/qequ/pyrite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qequ%2Fpyrite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qequ%2Fpyrite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qequ%2Fpyrite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qequ%2Fpyrite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qequ","download_url":"https://codeload.github.com/qequ/pyrite/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qequ%2Fpyrite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281403407,"owners_count":26495042,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-28T02:00:06.022Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["complex-numbers","crystal-lang","mathematics","numerical-methods","prng","root-finding","scientific-computing","statistics"],"created_at":"2024-10-05T00:23:23.770Z","updated_at":"2025-10-28T07:36:22.377Z","avatar_url":"https://github.com/qequ.png","language":"Crystal","readme":"# Pyrite\n\n\u003cimg src=\"./logo/pyrite_logo.png\" alt=\"Pyrite Logo\" width=\"200\"/\u003e\n\nPyrite is a Crystal library for scientific computing, heavily inspired by the SciLua library. It provides a range of functionalities including complex numbers, special mathematical functions, pseudorandom number generators (PRNGs), root-finding algorithms, and statistical distributions. Pyrite is designed for applications requiring high performance and accurate computations in scientific and engineering domains.\n\n## Installation\n\nAdd this to your application's shard.yml:\n\n```yaml\ndependencies:\n  pyrite:\n    github: qequ/pyrite\n```\n\nThen run:\n\n```bash\n$ shards install\n```\n\n## Usage\n\n### Complex Numbers\n\n```crystal\n\nrequire \"pyrite/complex\"\n\n# Creating complex numbers\nc1 = ComplexNumbers::Complex.new(2.0, 3.0)\nc2 = ComplexNumbers::Complex.new(1.0, 3.0)\n\n# Operations\nsum = c1 + c2\ndifference = c1 - c2\nproduct = c1 * c2\nquotient = c1 / c2\nmagnitude = c1.abs\n\nputs \"Sum: #{sum}\"\nputs \"Difference: #{difference}\"\nputs \"Product: #{product}\"\nputs \"Quotient: #{quotient}\"\nputs \"Magnitude of c1: #{magnitude}\"\n\n```\n\n### Mathematical Functions\n    \n```crystal\nrequire \"pyrite/math\"\n\n# Special functions and constants\nputs \"Pi: #{Pyrite::Math::PI}\"\nputs \"Absolute value: #{Pyrite::Math.abs(-3.5)}\"\nputs \"Phi function: #{Pyrite::Math.phi(1.0)}\"\n```\n\n### Pseudorandom Number Generators\n\n```crystal\nrequire \"pyrite/prng\"\n\n# Kiss99 PRNG\nrng = Pyrite::PRNG::Kiss99.new\nputs \"Random number: #{rng.next_bits}\"\n```\n\n### Root-finding Algorithms\n\n```crystal\nrequire \"pyrite/root\"\n\n# Newton method example\nf = -\u003e(x : Float64) { x**2 - 2 }\nf_prime = -\u003e(x : Float64) { 2*x }\nroot, _ = Pyrite::Root.newton(f, f_prime, 0.0, 2.0) { false }\nputs \"Root of x^2 - 2: #{root}\"\n```\n\n### Statistical Distributions\n\n#### Normal Distribution\n\n```crystal\n\nrequire \"pyrite/stat\"\n\n# Normal Distribution with mean 0 and standard deviation 1\nnormal_dist = Pyrite::Stat::Normal.new(0.0, 1.0)\nputs \"PDF of normal distribution at 0: #{normal_dist.pdf(0.0)}\"\nputs \"Random sample from normal distribution: #{normal_dist.sample}\"\n\n```\n\n#### Exponential Distribution\n  \n```crystal\n# Exponential Distribution with lambda = 1.5\nexp_dist = Pyrite::Stat::Exponential.new(1.5)\nputs \"Mean of exponential distribution: #{exp_dist.mean}\"\nputs \"Random sample from exponential distribution: #{exp_dist.sample}\"\n\n```\n\n#### Uniform Distribution\n\n```crystal\n# Uniform Distribution between 0 and 1\nuniform_dist = Pyrite::Stat::Uniform.new(0.0, 1.0)\nputs \"PDF of uniform distribution at 0.5: #{uniform_dist.pdf(0.5)}\"\nputs \"Random sample from uniform distribution: #{uniform_dist.sample}\"\n  \n```\n\n#### Gamma Distribution\n\n```crystal\n\n# Gamma Distribution with alpha = 2.0 and beta = 3.0\ngamma_dist = Pyrite::Stat::Gamma.new(2.0, 3.0)\nputs \"Mean of gamma distribution: #{gamma_dist.mean}\"\nputs \"Random sample from gamma distribution: #{gamma_dist.sample}\"\n  \n```\n\n#### Beta Distribution\n\n```crystal\n# Beta Distribution with alpha = 2.0 and beta = 5.0\nbeta_dist = Pyrite::Stat::Beta.new(2.0, 5.0)\nputs \"PDF of beta distribution at 0.5: #{beta_dist.pdf(0.5)}\"\nputs \"Random sample from beta distribution: #{beta_dist.sample}\"\n\n```\n\n#### Log-Normal Distribution\n  \n```crystal\n\n# Log-Normal Distribution with mu = 0 and sigma = 1\nlog_normal_dist = Pyrite::Stat::LogNormal.new(0.0, 1.0)\nputs \"PDF of log-normal distribution at 1: #{log_normal_dist.pdf(1.0)}\"\nputs \"Random sample from log-normal distribution: #{log_normal_dist.sample}\"\n\n```\n\n#### Student-t Distribution\n  \n```crystal\n# Student-t Distribution with nu = 10\nstudent_dist = Pyrite::Stat::Student.new(10)\nputs \"PDF of student-t distribution at 0: #{student_dist.pdf(0.0)}\"\nputs \"Random sample from student-t distribution: #{student_dist.sample}\"\n\n```\n\n\n## Development\n\nAfter checking out the repo, run shards install to install dependencies. Then, run `crystal spec` to run the tests.\n\n\n## Roadmap\n\nPyrite is continuously evolving, and there are several features and enhancements planned for future releases. The following is a list of potential additions to the library:\n\n- Quasi Random Number Generators (QRNGs): Implement advanced random number generators that can produce quasi-random sequences, offering better coverage of the space than standard pseudorandom number generators.\n\n- Differentiation: Include numerical differentiation capabilities to calculate derivatives of functions, which are essential in various scientific computations.\n\n- Interpolation: Develop methods for interpolating data points, useful in data analysis, curve fitting, and creating smoother transitions between discrete data points.\n\n- Matrix and Algebra: Expand the library to include matrix operations and linear algebra functionalities, which are fundamental in many scientific and engineering applications.\n\n- Optimization Algorithms: Integrate optimization algorithms for finding minima/maxima of functions, which are crucial in fields like machine learning, economics, and engineering design.\n\n- Statistical Analysis Tools: Enhance the statistical capabilities of the library with tools for data analysis, hypothesis testing, regression, and other statistical methods.\n\n- Numerical Integration (Quadrature): Add methods for numerical integration to approximate the integral of functions, a common task in many scientific fields.\n\n- Time Series Analysis: Implement functionality for analyzing and manipulating time series data, important in fields such as finance, economics, and meteorology.\n\n- Signal Processing: Include tools for analyzing, modifying, and synthesizing signals, useful in audio processing, telecommunications, and control systems.\n\n- Graphical and Visualization Tools: Develop visualization tools for data exploration and presentation, an important aspect of data analysis and scientific research.\n\n- Expand Statistical Distributions: Add more statistical distributions and enhance existing ones to cover a wider range of applications.\n\n- Parallel and Distributed Computing: Explore opportunities to leverage Crystal's concurrency model for parallel and distributed computing.\n\nThese enhancements aim to make Pyrite a more comprehensive toolkit for scientific computing in Crystal, catering to a wide range of applications and user needs.\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/qequ/pyrite/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Alvaro Frias Garay](https://github.com/qequ) - creator and maintainer\n\n\nThis project is based on and inspired by [SciLua](https://github.com/stepelu/lua-sci). The goal of Pyrite is to bring similar capabilities to the Crystal language, leveraging its performance and syntax features.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqequ%2Fpyrite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqequ%2Fpyrite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqequ%2Fpyrite/lists"}