In [1]:
#課題1 高橋 雅士  
#関数の定義はこちら https://github.com/masashitshit/Interpolations.jl/blob/master/src/Interpolations.jl

In [2]:
Pkg.clone("https://github.com/masashitshit/Interpolations.jl")


INFO: Cloning Interpolations from https://github.com/masashitshit/Interpolations.jl
Interpolations already exists

 in clone(::String, ::SubString{String}) at .\pkg\entry.jl:193
 in clone(::String) at .\pkg\entry.jl:221
 in (::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}})() at .\pkg\dir.jl:31
 in cd(::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}}, ::String) at .\file.jl:48
 in #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, ::Vararg{Any,N}) at .\pkg\dir.jl:31
 in clone(::String) at .\pkg\pkg.jl:151

In [3]:
Pkg.checkout("Interpolations", "master")


INFO: Checking out Interpolations master...
INFO: Pulling Interpolations latest master...
WARNING: unknown Interpolations commit 6e02f883, metadata may be ahead of package cache
WARNING: unknown Interpolations commit d36fe855, metadata may be ahead of package cache
WARNING: unknown Interpolations commit 0ecd53b6, metadata may be ahead of package cache
WARNING: unknown Interpolations commit 734f4aac, metadata may be ahead of package cache
WARNING: unknown Interpolations commit b67c920f, metadata may be ahead of package cache
WARNING: unknown Interpolations commit e2a0380a, metadata may be ahead of package cache
WARNING: unknown Interpolations commit 5b8c7c48, metadata may be ahead of package cache
WARNING: unknown Interpolations commit b11bdd50, metadata may be ahead of package cache
WARNING: unknown Interpolations commit 563d753b, metadata may be ahead of package cache
WARNING: unknown Interpolations commit 70e41285, metadata may be ahead of package cache
WARNING: unknown Interpolations commit 8c121161, metadata may be ahead of package cache
WARNING: unknown Interpolations commit 422a9347, metadata may be ahead of package cache
WARNING: unknown Interpolations commit 5511d40b, metadata may be ahead of package cache
WARNING: unknown Interpolations commit 716d9b49, metadata may be ahead of package cache
WARNING: unknown Interpolations commit 906bac2b, metadata may be ahead of package cache
WARNING: unknown Interpolations commit e8464501, metadata may be ahead of package cache
WARNING: unknown Interpolations commit 37fee94f, metadata may be ahead of package cache
WARNING: unknown Interpolations commit 614f7db7, metadata may be ahead of package cache
WARNING: unknown Interpolations commit 7646fe92, metadata may be ahead of package cache
INFO: No packages to install, update or remove

In [4]:
Pkg.test("Interpolations")


INFO: Testing Interpolations
INFO: Interpolations tests passed

In [5]:
using Interpolations
using Plots

In [6]:
plotlyjs()


Plotly javascript loaded.

To load again call

init_notebook(true)

WARNING: Method definition describe
Out[6]:
Plots.PlotlyJSBackend()
(

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


AbstractArray) in module StatsBase at C:\Users\Masashi Takahashi\.julia\v0.5\StatsBase\src\scalarstats.jl:573 overwritten
Out[7]:
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 [8]:
li = linerinterp(grid,vals)


 in module DataFrames at C:\Users\Masashi Takahashi\.julia\v0.5\DataFrames\src\abstractdataframe\abstractdataframe.jl:407.
Out[8]:
(::funfun) (generic function with 1 method)

In [9]:
li(0.3)


Out[9]:
0.25244129544236893

In [10]:
gridf = -7:0.1:7  
plot(gridf, sin.(gridf), label="sine function")
scatter!(grid, vals, label="sampled data", markersize=4)


Out[10]:

In [11]:
gridf = -7:0.1:7  
y_linear_qe = li.(gridf)


Out[11]:
141-element Array{Float64,1}:
 -0.656987  
 -0.563346  
 -0.469706  
 -0.376066  
 -0.282426  
 -0.188786  
 -0.0951453 
 -0.00150513
  0.0921351 
  0.185775  
  0.279415  
  0.347366  
  0.415317  
  ⋮         
 -0.347366  
 -0.279415  
 -0.185775  
 -0.0921351 
  0.00150513
  0.0951453 
  0.188786  
  0.282426  
  0.376066  
  0.469706  
  0.563346  
  0.656987  

In [12]:
plot(gridf, y_linear_qe, label="linear")
scatter!(grid, vals, label="sampled data", markersize=4) #置き換えができた!!


Out[12]: