LoginSignup
60

More than 5 years have passed since last update.

Juliaの開発環境を構築してみる(IJulia)

Last updated at Posted at 2013-12-10

Juliaとは?

先日TwitterでRのパッケージRcppやlme4などのパッケージを開発している
Doug Batesという方が saying "goodbye" to R してJuliaにシフトする旨
宣言されたということで名前を知りました。

参考
https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20131209/ec911711/attachment.pl
http://d.hatena.ne.jp/amarui/20120221/1329823079

公式サイト http://julialang.org/ のベンチマークを見るとRより圧倒的に速く、更にPythonやGoよりも速いとの事で興味が湧いて触ってみました。

やること

Mac OS Xに公式サイトに書かれている、IPythonを使ったブラウザベースのJulia開発環
A powerful browser-based graphical notebook interface to Julia.
を構築してみます。

以下の流れになります。

  1. Juliaインストール
  2. 環境変数設定
  3. Julia起動、IJuliaインストール
  4. パッケージインストール
  5. IJulia起動

かなり導入の敷居は低いです。

本手順の前提条件

  • Pythonがインストールされていてpipが使える
  • Mac OS X
  • Homebrewが利用可能

1. Juliaインストール

公式サイトからダウンロードしてきて、他のアプリケーション同様にインストールする
だけです。省略します。

2. 環境変数設定

私は以下のように設定しました。

bash
vim .bash_profile
bash
export PATH=$PATH:/Applications/Julia-0.2.0.app/Contents/Resources/julia/bin
bash
. .bash_profile

3. IPythonインストール

bash
pip install pyzmq
pip install tornado
pip install IPython

4. Julia起動、IJulia,PyPlotパッケージインストール

bash
julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "help()" to list help topics
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.2.0 (2013-11-16 23:44 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org release
|__/                   |  x86_64-apple-darwin12.5.0

julia> Pkg.add("IJulia")
...
..
INFO: REQUIRE updated.

julia> Pkg.add("PyPlot")
...
..
INFO: REQUIRE updated.

以上です、自動でgithubからソースがダウンロードされてビルドされます。
途中でエラーになった際には

Julia
Pkg.build()

で再実行できます。

5. IJulia起動

bash
ipython notebook --profile julia

5. 試してみる

これでIJuliaがデフォルトブラウザで起動しますので、試しに[New Notebook]で以下の
コードを実行してみると、

Julia
Pkg.add("RDatasets")
Pkg.add("Gadfly")
using RDatasets
using Gadfly
set_default_plot_size(9inch, 9inch/golden);
plot(dataset("datasets", "iris"), x = "SepalWidth", y = "SepalLength", color="Species")

http://julialang.org/
の下部にあるような、みんな大好きRのirisデータセットを使ったD3.jsの綺麗なチャートが出力されます。

My_First_Julian.png

素敵ですね!!!!

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
60