小住真央です。

テストの実行


In [2]:
Pkg.test("MyInterpolations")


INFO: Testing MyInterpolations
INFO: MyInterpolations tests passed

In [3]:
using MyInterpolations

In [4]:
using Plots

In [5]:
plotlyjs()


Plotly javascript loaded.

To load again call

init_notebook(true)

WARNING: Method definition describe(AbstractArray) in module StatsBase at C:\Users\mao21\.julia\v0.5\StatsBase\src\scalarstats.jl:573 overwritten in module DataFrames at C:\Users\mao21\.julia\v0.5\DataFrames\src\abstractdataframe\abstractdataframe.jl:407.
Out[5]:
Plots.PlotlyJSBackend()

In [6]:
grid = -7:7
vals = sin.(grid)


Out[6]:
15-element Array{Float64,1}:
 -0.656987
  0.279415
  0.958924
  0.756802
 -0.14112 
 -0.909297
 -0.841471
  0.0     
  0.841471
  0.909297
  0.14112 
 -0.756802
 -0.958924
 -0.279415
  0.656987

In [7]:
li = my_lin_interp(grid,vals)
grid = -7:7
vals = sin.(grid)

plot(grid, li, label="linear")
scatter!(grid, vals, label="sampled data",markersize=4)


Out[7]:

In [8]:
h(x) = 2 .* cos.(6x) .+ sin.(14x) .+ 2.5
c_grid = 0:.2:1
n = length(c_grid)

Af = my_lin_interp(c_grid, h(c_grid))

h_grid = linspace(0, 1, 150)

plot(h_grid, h, color=:blue, linewidth=2, alpha=0.8, label="true function")
plot!(h_grid, Af.(h_grid), color=:green, linewidth=2, alpha=0.8,
      label="linear approximation", legend=:top, grid=false)
N = repmat(c_grid, 1, 2)'
heights = [zeros(1,n); h(c_grid)']
plot!(N, heights, color=:black, linestyle=:dash, alpha=0.5, label="")


Out[8]:

In [ ]: