Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

public static double[][] selectKernelSet(double[][] trainingSet, double kernelPr

ID: 3646862 • Letter: P

Question

public static double[][] selectKernelSet(double[][] trainingSet, double kernelProportion, Random rng){

/*Create a new 2D array for the kernel set.
number of rows: kernelProportion times number of rows in trainingSet
cast the result of this calculation to an int
number of cols: same as the number of cols in trainingSet

Each row of the kernel set is assigned a random row of the trainingSet
using the random number generator to generate integers in the range 0 up to but not including the length of the trainingSet. Note it is okay if the same example is selected more than once./

Can anyone help me write a method for this ??

Explanation / Answer

Generally, creating two dimensional arrays is very similar to creating one dimensional arrays. Some languages allow you to create two dimensional arrays simply by adding an index item, however JavaScript doesn't support two dimensional arrays. JavaScript, does however, allow you to simulate a two dimensional array. You can do this by creating an "array of an array". To do this, you create an array, loop through the array, and for each element, you create another array. Then, you simply add an index for each column of your grid. In JavaSript this would look something like this: var faq = new Array(3) for (i=0; i