Skip to main content

Posts

First post using stackedit

Welcome to StackEdit! Hey! I’m your first Markdown document in StackEdit 1 . Don’t delete me, I’m very helpful! I can be recovered anyway in the Utils tab of the Settings dialog. Documents StackEdit stores your documents in your browser, which means all your documents are automatically saved locally and are accessible offline! Note: StackEdit is accessible offline after the application has been loaded for the first time. Your local documents are not shared between different browsers or computers. Clearing your browser’s data may delete all your local documents! Make sure your documents are synchronized with Google Drive or Dropbox (check out the Synchronization section). Create a document The document panel is accessible using the button in the navigation bar. You can create a new document by clicking New document in the document panel. Switch to another document All your local documents are listed in the document panel. You can switch from one to anoth
Recent posts

Install latest R (3.2.5) on Debian Jessie

Installing R on Ubuntu/Debian is quite painful, especially when you want to install the latest version. I have no clue why this situation stills for a long time, but this is a way to work around. On terminal: ```bash Appends the CRAN repository to your sources.list file You could replace jessie-cran3 by the newer one Find the correct value at https://cloud.r-project.org/ sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/debian jessie-cran3/" >> /etc/apt/sources.list' Adds the CRAN GPG key, which is used to sign the R packages for security. sudo apt-key adv --keyserver subkeys.pgp.net --recv-key 381BA480 sudo apt-get update sudo apt-get install r-base r-base-dev ``` Installing h2o : ```bash to retrieve curl-config otherwise you may have a problem with RCurl sudo apt-get install libcurl4-gnutls-dev ``` R install.packages ("h2o")

Using markdown with blogspot

How to use markdown with blogspot Originally, BlogSpot does not support markdown very well. It makes its disadvantage compared with new services such as github.io. However, we still can write markdown then post it to blogspot with online tools. Markdown editor I am using http://dillinger.io/ but there are other services. Convert Markdown code to HTML code Dillinger can export Markdown code to HTML code, but we have to download a new generated HTML file. I do not like it so much, so there is a website http://daringfireball.net/projects/markdown/dingus so we can convert and get HTML code directly, then just copy and paste it to Blogspot.

Installing tensorflow on Mac OS 10.11

Tensorflow (https://www.tensorflow.org/) is the open source deep learning library from Google (http://www.wired.com/2015/11/google-open-sources-its-artificial-intelligence-engine/). Installing Tensorflow is not easy on Mac if you follow exactly the installation instruction on the homepage. I have no idea why. I have error then error while trying to install Tensorflow with pip, with virtualenv, or even with Docker. However, with Anaconda (https://www.continuum.io/downloads), it will be easy. The trick is you should download the wheel file and install it offline other than retrieving it online as suggested by Tensorflow homepage. So, with anaconda for python2 installed, I did: # create a new environment with sklearn installed, up to you # if you want a pure Python, replace scikit-learn by python conda create -n tensorflow scikit-learn # activate the new environment source activate tensorflow # download the wheel file curl https://storage.googleapis.com/tensorflo

Testing the difference between two correlations in R

Introduction Correlation is the measurement to measure how two datasets increase or decrease together. It's a real number range from -1 (i.e, when one dataset increases, another one decreases and vice versa) to +1 (i.e, these two datasets increase or decrease together). Value 0 means there is no relationship between two datasets. Calculating correlation Calculating correlation of two datasets in R is quite straightforward: In R: > x = c (1,5,2,6,7) > y = c (2,4,3,9,-5) > cor(x,y) [1] -0.1459338 Usually, a single value does not say much in statistics. You need a confidence level. > cor.test (x, y) Pearson's product-moment correlation data:  x and y t = -0.2555, df = 3, p-value = 0.8149 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval:  -0.9109173  0.8451475 sample estimates:        cor  -0.1459338  The function 'cor.test' will gives you the correlation, and also 95% confidence level of

An interesting card game

Here is a very interesting card game which has been introduced by Prof. Kandori at University of Tokyo. There are two players, one is Red and one is Black. Each players have four cards in corresponding colors: King (K), Ace (A), 2 and 3. Each round, both two players simultaneously (i.e, together) select one card from their hand, and determine the winner as the rule in the picture: - If two cards are two Kings, Red wins. - If one card is King and other card is not, Black wins. - Otherwise, if number of two cards are different, Red wins. If number of two cards are identical, Black wins. At first sight, it is very easy to say that the game is favor on Red. But it is not true. Even if both players play randomly, the Black has a bigger chance to win. You can check the simulation at: http://www.codeskulptor.org/#user39_B0DWPHGSyD_1.py It is easy to calculate the chance to win of Black is 9/16. But we can go further. Take into account the fact that K is very important