March07's picture
add batch 3/5 (200 files)
803451e verified
Raw
History Blame Contribute Delete
17.1 kB
{"text": "function sim = gaussianKernel(x1, x2, sigma)\n%RBFKERNEL returns a radial basis function kernel between x1 and x2\n% sim = gaussianKernel(x1, x2) returns a gaussian kernel between x1 and x2\n% and returns the value in sim\n\n% Ensure that x1 and x2 are column vectors\nx1 = x1(:); x2 = x2(:);\n\n% You need to return the following variables correctly.\nsim = 0;\n\n% ====================== YOUR CODE HERE ======================\n% Instructions: Fill in this function to return the similarity between x1\n% and x2 computed using a Gaussian kernel with bandwidth\n% sigma\n%\n%\n\n\nsim = exp(-sum((x1-x2).^2)/(sigma.^2*2));\n\n\n\n% =============================================================\n \nend\n", "meta": {"author": "Ayatans", "repo": "Machine-Learning-homework", "sha": "4550cfc0426c9da8072dff165130fff40d138c10", "save_path": "github-repos/MATLAB/Ayatans-Machine-Learning-homework", "path": "github-repos/MATLAB/Ayatans-Machine-Learning-homework/Machine-Learning-homework-4550cfc0426c9da8072dff165130fff40d138c10/machine-learning-ex6/ex6/gaussianKernel.m", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9748211553734217, "lm_q2_score": 0.9353465066875933, "lm_q1q2_score": 0.9117955623236936}}
{"text": "function sim = gaussianKernel(x1, x2, sigma)\n%RBFKERNEL returns a radial basis function kernel between x1 and x2\n% sim = gaussianKernel(x1, x2) returns a gaussian kernel between x1 and x2\n% and returns the value in sim\n\n% Ensure that x1 and x2 are column vectors\nx1 = x1(:); x2 = x2(:);\n\n% You need to return the following variables correctly.\nsim = 0;\n\n% ====================== YOUR CODE HERE ======================\n% Instructions: Fill in this function to return the similarity between x1\n% and x2 computed using a Gaussian kernel with bandwidth\n% sigma\n%\n%\n\n\nsim = exp(-sum((x1-x2).^2)/2/(sigma^2));\n\n\n\n% =============================================================\n \nend\n", "meta": {"author": "zzlyw", "repo": "machine-learning-exercises", "sha": "10f91ee832f4e64607dafa634a27d115e0744cb5", "save_path": "github-repos/MATLAB/zzlyw-machine-learning-exercises", "path": "github-repos/MATLAB/zzlyw-machine-learning-exercises/machine-learning-exercises-10f91ee832f4e64607dafa634a27d115e0744cb5/machine-learning-ex6/ex6/gaussianKernel.m", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9740426412951847, "lm_q2_score": 0.9353465102920899, "lm_q1q2_score": 0.911067385411141}}
{"text": "function sim = gaussianKernel(x1, x2, sigma)\n%RBFKERNEL returns a radial basis function kernel between x1 and x2\n% sim = gaussianKernel(x1, x2) returns a gaussian kernel between x1 and x2\n% and returns the value in sim\n\n% Ensure that x1 and x2 are column vectors\nx1 = x1(:); x2 = x2(:);\n\n% You need to return the following variables correctly.\nsim = 0;\n\n% ====================== YOUR CODE HERE ======================\n% Instructions: Fill in this function to return the similarity between x1\n% and x2 computed using a Gaussian kernel with bandwidth\n% sigma\n%\n%\n\nsim = exp((- sum((x1 - x2) .^ 2)) / (2 * (sigma ^ 2)));\n\n% =============================================================\n \nend\n", "meta": {"author": "UtkarshPathrabe", "repo": "Machine-Learning-Stanford-University-Coursera", "sha": "0e5855855b5ddd475775b75bad69b47c2ebe84ef", "save_path": "github-repos/MATLAB/UtkarshPathrabe-Machine-Learning-Stanford-University-Coursera", "path": "github-repos/MATLAB/UtkarshPathrabe-Machine-Learning-Stanford-University-Coursera/Machine-Learning-Stanford-University-Coursera-0e5855855b5ddd475775b75bad69b47c2ebe84ef/Programming Exercises/machine-learning-ex6/ex6/gaussianKernel.m", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9688561721629776, "lm_q2_score": 0.9399133557169235, "lm_q1q2_score": 0.9106408559847576}}
{"text": "%% Project: 1-D Finite Difference Method\n%\n% The purpose of this project is to introduce the finite difference. We use\n% 1-D Poisson equation in (0,1) with Dirichlet boundary condition\n%\n% $$ - u'' = f \\, (0,1), \\quad u(0) = a, u(1) = b. $$\n\n%% Step 1: Generate a grid\n%\n% Generate a vector representing a uniform grid with size h of (0,1).\nN = 10;\nx = linspace(0,1,N);\nplot(x,0,'b.','Markersize',16)\n\n%% Step 2: Generate a matrix equation\n%\n% Based on the grid, the function $u$ is discretized by a vector |u|. The\n% derivative $u', u''$ are approximated by centeral finite difference:\n%\n% $$ u'(x_i) \\approx \\frac{u(i+1) - u(i-1)}{2h} $$\n%\n% $$ u''(x_i) \\approx \\frac{u(i-1) - 2*u(i) + u(i-1)}{h^2} $$ \n%\n% The equation $-u''(x) = f(x)$ is discretized at $x_i, i=1,...,N$ as\n%\n% $$ \\frac{-u(i-1) + 2*u(i) - u(i-1)}{h^2} \\quad = f(i) $$\n%\n% where $f(i) = f(x_i)$. These linear equations can be written as a matrix\n% equation |A*u = f|, where |A| is a tri-diagonal matrix |(-1,2,-1)/h^2|.\nn = 5;\ne = ones(n,1);\nA = spdiags([e -2*e e], -1:1, n, n);\ndisplay(full(A));\n%%\n% We use spdiags to speed up the generation of the matrix. If using diag,\n% ....\n\n%% Stpe 3: Modify the matrix and right hand side to impose boundary condition\n% \n% The discretization fails at boundary vertices since no nodes outside the\n% interval. Howevery the boundary value is given by the problem: |u(1) = a,\n% u(N) = b|.\n%\n% These two equations can be included in the matrix by changing |A(1,:) =\n% [1, 0 ..., 0] and A(:,N) = [0, 0, ..., 1] and |f(1) = a/h^2, f(N) =\n% b/h^2|.\nA(1,1) = 1;\nA(1,2) = 0;\nA(n,n) = 1;\nA(n,n-1) = 0;\ndisplay(full(A));\n\n%% Step 4: Test of code\n[u,x] = poisson1D(0,1,5);\nplot(x,sin(x),x,u,'r*');\nlegend('exact solution','approximate solution')\n%%\n% We test ... The result seems correct since the computed solution fits\n% well on the curve of the true solution.\n\n%% Step 5: Check the Convergence Rate\nerr = zeros(4,1);\nh = zeros(4,1);\nfor k = 1:4\n [u,x] = poisson1D(0,1,2^k+1);\n uI = sin(x);\n err(k) = max(abs(u-uI));\n h(k) = 1/2^k;\nend\ndisplay(err)\nloglog(h,err,h,h.^2);\nlegend('error','h^2');\naxis tight;\n%%\n% Since these two lines have the same lope, the err decays like h^2.\n", "meta": {"author": "wme7", "repo": "Aero-matlab", "sha": "9430008f2e3b84f28633775a44dff534e780fbac", "save_path": "github-repos/MATLAB/wme7-Aero-matlab", "path": "github-repos/MATLAB/wme7-Aero-matlab/Aero-matlab-9430008f2e3b84f28633775a44dff534e780fbac/iFEM/project/projectFDM1D.m", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9637799472560581, "lm_q2_score": 0.9425067236219976, "lm_q1q2_score": 0.9083690803808889}}
{"text": "function y = sigmoid(x,c,a)\n% sigmoid evaluates a simple sigmoid function along x: \n% \n% ______1________\n% y = -a(x-c)\n% 1 + e^\n% \n%% Syntax \n% \n% y = sigmoid(x)\n% y = sigmoid(x,c)\n% y = sigmoid(x,c,a)\n% \n%% Description\n% \n% y = sigmoid(x) generates a sigmoid function along x. \n% \n% y = sigmoid(x,c) makes a sigmoid that scaled from zero to one, where\n% c corresponds to the x value where y = 0.5. If c is not specified, a\n% default value of c = 0 is assumed. \n% \n% y = sigmoid(x,c,a) specifies a, the rate of change. If a is close to\n% zero, the sigmoid function will be gradual. If a is large, the sigmoid\n% function will have a steep or sharp transition. If a is negative, the \n% sigmoid will go from 1 to zero. A default value of a = 1 is assumed if \n% a is not declared. \n% \n%% Example 1 \n% A simple sigmoid: \n% \n% x = -10:.01:10;\n% plot(x,sigmoid(x))\n% \n%% Example 2: \n% Make a sigmoid function along x = 1 to 100, such that y(x=60) = 0.5: \n% \n% x = 1:100; \n% y = sigmoid(x,60);\n% plot(x,y,'b','linewidth',2) \n% \n% Now do the same thing as above, but make the transition more gradual: \n% \n% y2 = sigmoid(x,60,0.1); \n% hold on\n% plot(x,y2,'r','linewidth',2) \n% legend('default a = 1','a = 1/10') \n% legend boxoff \n% \n%% Author Info:\n% Chad Greene, May 28, 2015. \n% http://www.chadagreene.com\n\n%% Parse Inputs: \n\nnarginchk(1,3) \nif nargin<3\n a = 1; \nelse\n assert(isscalar(a)==1,'a must be a scalar.') \nend\n\nif nargin<2\n c = 0; \nelse\n assert(isscalar(c)==1,'c must be a scalar.') \nend\n\n%% Perform mathematics: \n\ny = 1./(1 + exp(-a.*(x-c)));\n", "meta": {"author": "buzsakilab", "repo": "buzcode", "sha": "2d700a38b3c2a860ad1333be90f14d7a37a72815", "save_path": "github-repos/MATLAB/buzsakilab-buzcode", "path": "github-repos/MATLAB/buzsakilab-buzcode/buzcode-2d700a38b3c2a860ad1333be90f14d7a37a72815/utilities/sigmoid.m", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9585377308419049, "lm_q2_score": 0.9473810468379927, "lm_q1q2_score": 0.9081004788787179}}
{"text": "function sim = gaussianKernel(x1, x2, sigma)\n%RBFKERNEL returns a radial basis function kernel between x1 and x2\n% sim = gaussianKernel(x1, x2) returns a gaussian kernel between x1 and x2\n% and returns the value in sim\n\n% Ensure that x1 and x2 are column vectors\nx1 = x1(:); x2 = x2(:);\n\n% You need to return the following variables correctly.\nsim = 0;\n\n% ====================== YOUR CODE HERE ======================\n% Instructions: Fill in this function to return the similarity between x1\n% and x2 computed using a Gaussian kernel with bandwidth\n% sigma\n%\n%\n\n\nsim = exp( -1 * sum((x1 - x2).^2) / (2 * (sigma ^ 2)));\n\n\n% =============================================================\n \nend\n", "meta": {"author": "gopaczewski", "repo": "coursera-ml", "sha": "9f68b71ac6b65bfd7cea32c7c22b4abd40401579", "save_path": "github-repos/MATLAB/gopaczewski-coursera-ml", "path": "github-repos/MATLAB/gopaczewski-coursera-ml/coursera-ml-9f68b71ac6b65bfd7cea32c7c22b4abd40401579/mlclass-ex6-005/mlclass-ex6/gaussianKernel.m", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9693241974031599, "lm_q2_score": 0.9353465053359071, "lm_q1q2_score": 0.9066540005785786}}
{"text": "function y=hav(x)\n%%HAV Compute the haversine of x. The haversine arises in navigation\n% problems. As in [1], it is just sin(x/2).^2. Haversines tend to arise\n% in navigation problems.\n%\n%INPUTS: x A numeric matrix.\n%\n%OUTPUTS: y The haversine of x. y has the same dimensionality as x.\n%\n%REFERENCES:\n%[1] Weisstein, Eric W. \"Haversine.\" From MathWorld--A Wolfram Web\n% Resource. https://mathworld.wolfram.com/Haversine.html\n%\n%October 2022 David F. Crouse, Naval Research Laboratory, Washington D.C.\n%(UNCLASSIFIED) DISTRIBUTION STATEMENT A. Approved for public release.\n\ny=sin(x/2).^2;\n\nend\n\n%LICENSE:\n%\n%The source code is in the public domain and not licensed or under\n%copyright. The information and software may be used freely by the public.\n%As required by 17 U.S.C. 403, third parties producing copyrighted works\n%consisting predominantly of the material produced by U.S. government\n%agencies must provide notice with such work(s) identifying the U.S.\n%Government material incorporated and stating that such material is not\n%subject to copyright protection.\n%\n%Derived works shall not identify themselves in a manner that implies an\n%endorsement by or an affiliation with the Naval Research Laboratory.\n%\n%RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF THE\n%SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY THE NAVAL\n%RESEARCH LABORATORY FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE ACTIONS\n%OF RECIPIENT IN THE USE OF THE SOFTWARE.\n", "meta": {"author": "USNavalResearchLaboratory", "repo": "TrackerComponentLibrary", "sha": "9f6e329de5be06a371757c4b853200beb6def2d0", "save_path": "github-repos/MATLAB/USNavalResearchLaboratory-TrackerComponentLibrary", "path": "github-repos/MATLAB/USNavalResearchLaboratory-TrackerComponentLibrary/TrackerComponentLibrary-9f6e329de5be06a371757c4b853200beb6def2d0/Mathematical_Functions/hav.m", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9621075777163566, "lm_q2_score": 0.9407897480136238, "lm_q1q2_score": 0.905140945601769}}
{"text": "function area=hypersphereArea(r,numDim)\n%%HYPERSPHEREAREA Determine the surface area of a hypersphere of a given\n% radius in a given number of dimensions.\n%\n%INPUTS: r The radius of the hypersphere. r>0.\n% numDim The number of dimensions of the hypersphere. numDim>=1. One\n% dimensions is a line, two a circle, three a sphere, etc.\n%\n%OUTPUTS: area The area of the hypersphere.\n%\n%The surface area of a hypersphere is given in terms of the gamma function\n%in [1].\n%\n%REFERENCES:\n%[1] S. Li, \"Concise formulas for the area and volume of a hyperspherical\n% cap,\" Asian Journal of Mathematics and Statistics, vol. 4, no. 1, pp.\n% 66-70, 2011.\n%\n%October 2016 David F. Crouse, Naval Research Laboratory, Washington D.C.\n%(UNCLASSIFIED) DISTRIBUTION STATEMENT A. Approved for public release.\n\narea=2*pi^(numDim/2)/gamma(numDim/2)*r^(numDim-1);\n\nend\n\n%LICENSE:\n%\n%The source code is in the public domain and not licensed or under\n%copyright. The information and software may be used freely by the public.\n%As required by 17 U.S.C. 403, third parties producing copyrighted works\n%consisting predominantly of the material produced by U.S. government\n%agencies must provide notice with such work(s) identifying the U.S.\n%Government material incorporated and stating that such material is not\n%subject to copyright protection.\n%\n%Derived works shall not identify themselves in a manner that implies an\n%endorsement by or an affiliation with the Naval Research Laboratory.\n%\n%RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF THE\n%SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY THE NAVAL\n%RESEARCH LABORATORY FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE ACTIONS\n%OF RECIPIENT IN THE USE OF THE SOFTWARE.\n", "meta": {"author": "USNavalResearchLaboratory", "repo": "TrackerComponentLibrary", "sha": "9f6e329de5be06a371757c4b853200beb6def2d0", "save_path": "github-repos/MATLAB/USNavalResearchLaboratory-TrackerComponentLibrary", "path": "github-repos/MATLAB/USNavalResearchLaboratory-TrackerComponentLibrary/TrackerComponentLibrary-9f6e329de5be06a371757c4b853200beb6def2d0/Mathematical_Functions/Geometry/hyperspheres/hypersphereArea.m", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9766692305124305, "lm_q2_score": 0.9263037328370258, "lm_q1q2_score": 0.90469235397073}}
{"text": "function sim = gaussianKernel(x1, x2, sigma)\n%RBFKERNEL returns a radial basis function kernel between x1 and x2\n% sim = gaussianKernel(x1, x2) returns a gaussian kernel between x1 and x2\n% and returns the value in sim\n\n% Ensure that x1 and x2 are column vectors\nx1 = x1(:); x2 = x2(:);\n\n% You need to return the following variables correctly.\nsim = 0;\n\n% ====================== YOUR CODE HERE ======================\n% Instructions: Fill in this function to return the similarity between x1\n% and x2 computed using a Gaussian kernel with bandwidth\n% sigma\n%\n%\n\nsim = exp(-sum((x1 - x2).^2)/(2 * sigma^2));\n\n% =============================================================\n \nend\n", "meta": {"author": "rmarquis", "repo": "coursera-machinelearning", "sha": "5b165935e6fecfab977b2af1b0e9c588c75ca8f4", "save_path": "github-repos/MATLAB/rmarquis-coursera-machinelearning", "path": "github-repos/MATLAB/rmarquis-coursera-machinelearning/coursera-machinelearning-5b165935e6fecfab977b2af1b0e9c588c75ca8f4/homework/mlclass-ex6/gaussianKernel.m", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9693241965169939, "lm_q2_score": 0.930458253083697, "lm_q1q2_score": 0.9019156985629603}}
{"text": "function sim = gaussianKernel(x1, x2, sigma)\n%RBFKERNEL returns a radial basis function kernel between x1 and x2\n% sim = gaussianKernel(x1, x2) returns a gaussian kernel between x1 and x2\n% and returns the value in sim\n\n% Ensure that x1 and x2 are column vectors\nx1 = x1(:); x2 = x2(:);\n\n% You need to return the following variables correctly.\nsim = 0;\n\n% ====================== YOUR CODE HERE ======================\n% Instructions: Fill in this function to return the similarity between x1\n% and x2 computed using a Gaussian kernel with bandwidth\n% sigma\n%\n%\n\nupper = sum((x1 .- x2) .^ 2);\nsim = exp(-upper / (2 * sigma ^ 2));\n\n\n\n% =============================================================\n \nend\n", "meta": {"author": "ecmadao", "repo": "Coding-Guide", "sha": "baac530f78b239488003de039b346ca0ba24ed6c", "save_path": "github-repos/MATLAB/ecmadao-Coding-Guide", "path": "github-repos/MATLAB/ecmadao-Coding-Guide/Coding-Guide-baac530f78b239488003de039b346ca0ba24ed6c/Notes/ml/coursera/machine-learning-ex6/ex6/gaussianKernel.m", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9678992932829918, "lm_q2_score": 0.931462509346239, "lm_q1q2_score": 0.9015619045158269}}