{"id":20977351,"url":"https://github.com/gusgitmath/regression_function","last_synced_at":"2026-04-21T08:31:00.715Z","repository":{"id":255376470,"uuid":"849415685","full_name":"GusGitMath/Regression_Function","owner":"GusGitMath","description":"This Python function fits user-defined functions to data using non-linear least squares optimization. It supports 2-4 parameters, custom initial values, error margins, and plotting. It calculates Chi-Squared statistics and covariance matrices, suitable for scientific data analysis and curve fitting tasks.","archived":false,"fork":false,"pushed_at":"2024-08-29T14:56:27.000Z","size":611,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-27T18:27:59.731Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GusGitMath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-29T14:55:15.000Z","updated_at":"2024-08-29T14:56:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"ea2f6261-8ec9-4923-8ed6-b6da6d3b0941","html_url":"https://github.com/GusGitMath/Regression_Function","commit_stats":null,"previous_names":["gusgitmath/regression_function"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/GusGitMath/Regression_Function","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GusGitMath%2FRegression_Function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GusGitMath%2FRegression_Function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GusGitMath%2FRegression_Function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GusGitMath%2FRegression_Function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GusGitMath","download_url":"https://codeload.github.com/GusGitMath/Regression_Function/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GusGitMath%2FRegression_Function/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32083586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T06:27:27.065Z","status":"ssl_error","status_checked_at":"2026-04-21T06:27:21.250Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-11-19T04:58:27.504Z","updated_at":"2026-04-21T08:31:00.679Z","avatar_url":"https://github.com/GusGitMath.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Function Fitting Utility\n\n**Date Written:** September 2020\n\n## Overview\n\nThis utility provides a convenient way to fit a user-defined function to a set of data points. The code performs the following tasks:\n\n1. **Curve Fitting:** Uses non-linear least squares optimization to fit a function to the provided `xdata` and `ydata`.\n2. **Error Estimation:** Computes the errors associated with the fitted parameters.\n3. **Plotting:** Visualizes the fitted function alongside the original data points, including error bars.\n4. **Chi-Squared Calculation:** Optionally calculates and displays the Chi-Squared and Reduced Chi-Squared values.\n5. **Covariance Matrix:** Optionally displays the covariance matrix of the fitted parameters.\n\n## Key Features\n\n- **Custom Function Input:** The function to be fitted can be customized by the user.\n- **Flexible Parameter Handling:** Supports fitting functions with 2 to 4 parameters.\n- **Error Handling:** Automatically handles errors in both `xdata` and `ydata` if provided.\n- **Plot Customization:** Allows for detailed customization of the plot appearance, including colors, labels, and titles.\n- **Statistical Output:** Can display important statistical information like Chi-Squared values and the covariance matrix.\n\n## Usage\n\n1. Define the data to be fitted (`xdata`, `ydata`).\n2. Define the function to be fitted.\n3. Call the `fit_function` with the required parameters.\n\nExample:\n```python\nxdata = np.linspace(0, 4, 50)\nydata = np.sin(xdata) + np.random.normal(0, 0.1, xdata.size)\n\ndef example_func(x, a, b, c):\n    return a * np.sin(b * x + c)\n\nparams, params_error = fit_function(xdata, ydata, example_func, n=3)\n```\n\n## Dependencies\n\n- `numpy`: For numerical operations and array handling.\n- `matplotlib`: For plotting the fitted functions and data points.\n- `scipy.optimize.curve_fit`: For performing the curve fitting.\n- `IPython.display`: For displaying formatted output in Jupyter notebooks.\n- `sympy`: For handling and displaying the covariance matrix.\n\n## Installation\n\nEnsure you have the required Python libraries installed:\n```bash\npip install numpy matplotlib scipy sympy\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgusgitmath%2Fregression_function","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgusgitmath%2Fregression_function","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgusgitmath%2Fregression_function/lists"}