30
30

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Julia 入門①

Last updated at Posted at 2018-09-22

はじめに

最近になって、Juliaという言語を知り、pythonより実行速度が早く、機械学習を始めとする科学計算が得意ということで、せっかく機械学習勉強し始めたし、Julia使ってみようかというのがこのメモの始まりです。

基本は自分が勉強した際の内容をざっくばらんにまとめているだけですが、ほんの僅かでも誰かの役に立てば幸いです。

juliaの関連サイトは下記の通りです。

公式サイト

A place to discuss all things Julia.

最近(2018年8月)にメジャーバージョンアップがあり、1.0.0がリリースされました。
なんで、このメモではJuliaのバージョンは1.0.0を使用しています。

$ julia --version
julia version 1.0.0

基本コマンド

1.起動

julia

2.終了

exit()

3.helpモード

?

juliaモードの状態で?だけタイプすると

help?>
search: ⊻ ⊋ ⊊ ⊉ ⊈ ⊇ ⊆ ≥ ≤ ≢ ≡ ≠ ≉ ≈ ∪ ∩ ∛ √ ∘ ∌ ∋ ∉ ∈ ℯ π ÷ ~ | ^ \ > < : / - +

  Welcome to Julia 1.0.0. The full manual is available at

  https://docs.julialang.org/

  as well as many great tutorials and learning resources:

  https://julialang.org/learning/

  For help on a specific function or macro, type ? followed by its name, e.g.
  ?cos, or ?@time, and press enter. Type ; to enter shell mode, ] to enter
  package mode.

と表示され、ドキュメントの場所を教えてくれる。
また、文法とかわからなくなった際に、forとかってタイプすると

help?> for
search: for foreach foldr floor mapfoldr factorial EOFError OverflowError

  for

  for loops repeatedly evaluate the body of the loop by iterating over a
  sequence of values.

  Examples
  ≡≡≡≡≡≡≡≡≡≡

  julia> for i in [1, 4, 0]
             println(i)
         end
  1
  4
  0
  

サンプルまで教えてくれる。

4.パッケージのインストール

using Pkg
Pkg.add(お好きなパッケージ)

5.インストール済みのパッケージの一覧を表示する

julia> using Pkg

julia> Pkg.installed()
Dict{String,Union{Nothing, VersionNumber}} with 9 entries:
  "Juno"        => v"0.5.3"
  "GR"          => v"0.34.1"
  "Genie"       => v"0.1.0"
  "IJulia"      => v"1.12.0"
  "Plots"       => v"0.20.2"
  "Flax"        => v"0.0.0"
  "Atom"        => v"0.7.6"
  "SearchLight" => v"0.1.0"
  "Gadfly"      => v"0.8.0"

6.パッケージの状態を確認

julia> Pkg.status()

7.パッケージを最新にする

julia> Pkg.update()

Jupyter をインストールしてみる

参考
JupyterでJuliaを動かして回帰分析をやってみる。

###インストール

インストールにちょっと時間かかります。

julia> using Pkg

julia> Pkg.add("IJulia")

###確認

julia> Pkg.installed()
Dict{String,Union{Nothing, VersionNumber}} with 9 entries:
  "Juno"        => v"0.5.3"
  "GR"          => v"0.34.1"
  "Genie"       => v"0.1.0"
  "IJulia"      => v"1.12.0"
  "Plots"       => v"0.20.2"
  "Flax"        => v"0.0.0"
  "Atom"        => v"0.7.6"
  "SearchLight" => v"0.1.0"
  "Gadfly"      => v"0.8.0"

たしかにIjuliaが入ってます。

###起動

julia> using IJulia

julia> IJulia.notebook()

で、自動的にブラウザが立ち上がり、Jupyter NoteBookの画面が立ち上がるはずです。

30
30
0

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
30
30

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?