-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathatan_sin_dataset.exs
More file actions
41 lines (32 loc) · 925 Bytes
/
atan_sin_dataset.exs
File metadata and controls
41 lines (32 loc) · 925 Bytes
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
36
37
38
39
40
41
defmodule AtanSin do
import Gnuplot
@moduledoc "http://gnuplot.sourceforge.net/demo/simple.7.gnu"
def png, do: Path.join("docs", "atan_sin_dataset.PNG")
def target,
do: [
[:set, :term, :png, :size, '512,256', :font, "/Library/Fonts/FiraCode-Medium.ttf", 12],
[:set, :output, png()]
]
def commands,
do: [
[
:plot,
"-",
:with,
:lines,
:title,
"sin(x*20)*atan(x)"
]
]
def plot, do: plot(target() ++ commands(), [dataset()])
defp dataset do
Enum.map(ffor(-30, 20, 800), fn x -> [x, :math.sin(x * 20) * :math.atan(x)] end)
end
# defp dataset2 do
# for x <- -30_000..20_000,
# do: [x / 1000.0, :math.sin(x * 20 / 1000.0) * :math.atan(x / 1000.0)]
# end
defp ffor(min, max, step), do: for(x <- min..max, dx <- 0..step, do: x + dx / step)
end
# mix run examples/atan_sin_dataset.exs
AtanSin.plot()