1. Largest interval
Given a list of numbers, write a function that return the largest interval, along with the size of the interval. For example, if the list consists of 3,1,5,20,18,11,1,7,6, then you will return interval [11,18] and interval size 7. One example of returned value is a data frame named as interval, such that interval$intL=11, interval$intR=18, interval$size=7.
Hint: an example R code can be found here.
2. Frequency counts
Given a list of numbers, and the number of intervals, write a function that return the count of numbers in each equal-sized interval. For example, if you are given a list consisting of the following numbers
3,1,5,20,18,11,1,7,6,33,28.1,21.9,15,11,9,25,29,30,10,14,15.1,17.5,22.4,25.9, 4.5, 2.1,35,0
and the number of intervals is 5, then you will return a list consisting of the counts in each of the following intervals
[0,7), [7,14), [14,21), [21,28), [28,35),
which are 8, 5, 6, 4, 5, respectively.
Hint: an example R code can be found here.
3. The third largest element in a list
Write a function that returns the value of the third largest (or second smallest) element of a given list.
4. Finding top K entries
The attached data, "trans.Rdata", is a transaction records file. The first column is time stamp of the transaction, and second the amount of transaction. Find the largest (in terms of transaction amount) K=10, 100, 1000, 10000 transactions within the last half year. Please write a primitive function, i.e., do not use R functions such as sort(), order(), or rank(). An example code can be found here.
5. Largest nearest neighbor distance
Use the following R code to generate 10^4 data points in the unit square.
> tmp<-runif(20000,0,1);
> x<-matrix(tmp, 10^4,2);
Define the nearest neighbor of a data point to be a data point that is closest to it (under Euclidean distance), and the associated distance is the nearest neighbor distance. So we would have 10^4 nearest neighbor distances (one for each data point). Write a function that finds the largest of these 10^4 distances. Here is an example R code.
1) Please describe your algorithm, and its computational complexity.
2) What is your result?
3) Please attach your R code.
6. Average k-nearest neighbor distances
Under the same setting as 3), find the average of k-nearest neighbor distance for k=1,2,3,4,5,10,20,50,100. Here is an R example code.
7. Convex hulls for a set of data points