Publications by R on Guangchuang Yu
the batman equation
HardOCP has an image with an equation which apparently draws the Batman logo. This function is very delightful for drawing such a graph, but write it down in latex is very tedious. As a product of factors is 0 if and only if any one of them is 0, multiplying these six factors puts the curves together. This graph is no more than the combination ...
1494 sym R (1179 sym/2 pcs) 14 img 1 tbl
ggplot2 Version of Figures in “25 Recipes for Getting Started with R”
In order to provide an option to compare graphs produced by basic internal plot function and ggplot2, I recreated the figures in the book, 25 Recipes for Getting Started with R, with ggplot2. The code used to create the images is in separate paragraphs, allowing easy comparison. 1.16 Creating a Scatter Plot plot(cars) ggplot(cars,aes(speed,dist...
1342 sym R (2826 sym/10 pcs) 20 img
Machine Learning Ex4 – Logistic Regression
Exercise 4 required implementing Logistic Regression using Newton’s Method. The dataset in use is 80 students and their grades of 2 exams, 40 students were admitted to college and the other 40 students were not. We need to implement a binary classification model to estimates college admission based on the student’s scores on these two exams. ...
3031 sym R (1886 sym/9 pcs) 8 img 4 tbl
Machine Learning Ex 5.1 – Regularized Linear Regression
The first part of the Exercise 5.1 requires to implement a regularized version of linear regression. Adding regularization parameter can prevent the problem of over-fitting when fitting a high-order polynomial. Plot the data: ?View Code RSPLUS1 2 3 4 5 6 7 8 9 x <- read.table("ex5Linx.dat") y <- read.table("ex5Liny.dat") x <- x[,1] y <- y[,1] ...
2474 sym R (1811 sym/10 pcs) 6 img 5 tbl
Machine Learning Ex 5.2 – Regularized Logistic Regression
Now we move on to the second part of the Exercise 5.2, which requires to implement regularized logistic regression using Newton’s Method. Plot the data: x <- read.csv("ex5Logx.dat", header=F) y <- read.csv("ex5Logy.dat", header=F) y <- y[,1] d <- data.frame(x1=x[,1],x2=x[,2],y=factor(y)) require(ggplot2) p <- ggplot(d, aes(x=x1, y=x2))+ g...
3172 sym R (2952 sym/7 pcs) 6 img
Project Euler-Problem 38
Take the number 192 and multiply it by each of 1, 2, and 3: 192 × 1 = 192 192 × 2 = 384 192 × 3 = 576 By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3) The same can be achieved by starting with 9 and multiplying by 1, 2, 3, 4, and 5, giving t...
669 sym R (1158 sym/3 pcs) 1 tbl
project euler-Problem 41
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandigital prime that exists? using gmp and permute package, this problem is very straightforward, and easy to solve. ?View Code RSPLUS1 2 3 4 5 6 7 8 9...
751 sym R (862 sym/4 pcs) 1 tbl
project euler-Problem 43
The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property. Let d1 be the 1st digit, d2 be the 2nd digit, and so on. In this way, we note the following: d2d3d4=406 is divisible by 2 d3d4d5=063 is divisible b...
722 sym R (1939 sym/4 pcs) 1 tbl
project euler – Problem 15
Starting in the top left corner of a 2x2 grid, there are 6 routes (without backtracking) to the bottom right corner. How many routes are there through a 20x20 grid? Using recursive algorithm can solved this problem well. For optimized the running time, I use a matrix to cache previously called functions, as I did in Problem 164. ?View Code RSPL...
837 sym R (684 sym/3 pcs) 1 tbl
project euler – Problem 31
In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation: 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p). It is possible to make £2 in the following way: 1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p How many different ways can £2 be made using any number of coins? Rec...
714 sym R (821 sym/4 pcs) 1 tbl