{"id":19182043,"url":"https://github.com/glentner/kernelfit","last_synced_at":"2025-10-06T01:42:54.243Z","repository":{"id":30084439,"uuid":"33634053","full_name":"glentner/KernelFit","owner":"glentner","description":"[C++] Single and multi-dimensional non-parametric Gaussian kernel regression.","archived":false,"fork":false,"pushed_at":"2015-04-15T16:20:03.000Z","size":23228,"stargazers_count":7,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T23:07:46.647Z","etag":null,"topics":["cpp-library","kernel","openmp","regression"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/glentner.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}},"created_at":"2015-04-08T21:48:55.000Z","updated_at":"2024-06-12T10:01:42.000Z","dependencies_parsed_at":"2022-07-28T00:47:26.441Z","dependency_job_id":null,"html_url":"https://github.com/glentner/KernelFit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glentner%2FKernelFit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glentner%2FKernelFit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glentner%2FKernelFit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glentner%2FKernelFit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/glentner","download_url":"https://codeload.github.com/glentner/KernelFit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252968118,"owners_count":21833251,"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","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":["cpp-library","kernel","openmp","regression"],"created_at":"2024-11-09T10:56:20.298Z","updated_at":"2025-10-06T01:42:49.223Z","avatar_url":"https://github.com/glentner.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KernelFit\n\nC++ classes for single and multidimensional non-parametric Gaussian kernel\nregression. These objects allow for the fitting of smooth profiles through\nnoisy data. The functions that solve for the profile are\n*embarrassingly parallel* and use OpenMP to gain large speedups.\n\n**License:**\n[GNU General Public License, version 3](https://www.gnu.org/copyleft/gpl.html).\nSee the LICENSE file.\n\n**Dependencies:**\nSTL and OpenMP\n\n**Exceptions:**\nThe KernelFit objects will throw `KernelFitError` when given unacceptable\ninputs for the constructors.\n\nThe header and source file, *KernelFit.hh* and *KernelFit.cc*, respectively\nare located in the *Source* directory. The user should simply put the header\nfile with the other header files for their project and compile, link the\nsource file with their other source files. The *Makefile* included with this\nrepository compiles and runs the test programs *TestKernelFit1D.cc* and\n*TestKernelFit2D.cc* in the *Test* directory. The figures included below\nrepresent the results of those programs.\n\n*Notice:*\nThe TestKernelFit2D.cc program took ~ 2 min to run on my MacBook Pro (Intel i5)\nusing 4 threads. This program (in addition to the other test program) will be\nrun automatically when `make` is executed.\n\n## Usage:\n\nAfter included the code in your project, you can use them similar to the\nbelow snippet:\n\n```C++\n#include \u003cKernelFit.hh\u003e\n```\n\n...\n\n\n```C++\nomp_set_num_threads(4);\n```\n\n...\n\n```C++\nKernelFit1D\u003cdouble\u003e kernel(x, y, bandwidth);\nstd::vector\u003cdouble\u003e profile = kernel.Solve(new_x);\n```\n\nInclude the header file (snippet 1). If you don't specify the desired maximum\nthread count with OpenMP (snippet 2), the *Solve()* method will choose for you.\nIn the last snippet, we create the kernel object with three arguments. The first\ntwo, `x` and `y` are `std::vector\u003cdouble\u003e`s and the last argument should be of\nthe same type but is a scalar. `new_x` should be similar to `x` and `y` but a\nnew line-space that you want to solve on.\n\nThe general approach here is described quite\nwell on the [Kernel Smoother](http://en.wikipedia.org/wiki/Kernel_smoother)\nWikipedia page. Here, `bandwidth` refers to the length scale, or explicitly,\nthe standard deviation in the Gaussian. Choosing the correct bandwidth here is\ncritical to getting a good fit. If your choice is too small, you'll essentially\nbe drawing strait lines between the data points. If your bandwidth is too large,\neverybody will be under the Gaussian together and we'll have almost a flat line\nwith a height of the average value of the data set.\n\nAs is evident by the last code snippet, the objects are *template* defined.\nAt this point, the only available type is *double*. In order to use different\ntypes simply add the following line to the bottom of KernelFit.cc\n\n```C++\ntemplate class KernelFit\u003cfloat\u003e;\n```\n\nwhere *float* was the desired type.\n\n![example](Figures/KernelFit1D.png \"Results of KernelFit1D\")\n\n**Figure** **1:** The above figure was plotting using Python and showcases the\nresults of the TestKernelFit1D.cc program. A noisy sinc function was produced\nwith both *red* and *white* noise. The blue dashed line demonstrates the smooth\nprofile fit through the data. The red dashed line shows the analytical function.\n\nThe usage for a 2D surface profile is very similar:\n\n```C++\nKernelFit2D\u003cdouble\u003e kernel(x, y, z, bandwidth);\nstd::vector\u003cstd::vector\u003cdouble\u003e\u003e profile = kernel.Solve(new_x, new_y);\n```\n\n![example](Figures/KernelFit2D.png \"Results of KernelFit1D\")\n\n**Figure** **2:** The above figure was plotting using Python and showcases the\nresults of the TestKernelFit2D.cc program. Just as in the example in Figure 1,\nA sinc function was used here as well but radially. The brown-red scatter points\nare the raw data produced. The *terrain* colored mesh grid showcases the\nsmooth surface profile generated by the KernelFit2D algorithm.\n\n\n## Author:\n\n**Geoffrey** **Lentner** \u003cbr /\u003e\nGraduate Research Assistant \u003cbr /\u003e\nDepartment of Physics \u0026 Astronomy \u003cbr /\u003e\nUniversity of Louisville\n\n**website:** [glentner.github.io](http://glentner.github.io)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglentner%2Fkernelfit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglentner%2Fkernelfit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglentner%2Fkernelfit/lists"}