-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrand.exs
35 lines (28 loc) · 779 Bytes
/
rand.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
defmodule Rand do
import Gnuplot
@moduledoc false
def png, do: Path.join("docs", "rand.PNG")
def target,
do: [
[:set, :term, :pngcairo, :size, '512,256', :font, "Fira Sans,12"],
[:set, :output, png()]
]
def commands,
do: [
~w(set key left top)a,
~w(set style line 1 lc rgb '#77216F' pt 13)a,
~w(set style line 2 lc rgb '#599B2B' pt 2)a,
plots([
["-", :title, "uniform", :with, :points, :ls, 1],
["-", :title, "normal", :with, :points, :ls, 2]
])
]
def data,
do: [
for(n <- 0..99, do: [n, n * :rand.uniform()]),
for(n <- 0..99, do: [n, n * :rand.normal()])
]
def draw, do: plot(target() ++ commands(), data())
end
# mix run examples/rand.exs
{:ok, _} = Rand.draw()