lin_interp_demo-checkpoint



In [1]:
# AkizukiLinearInterpolation by 4kizuki
# https://github.com/4kizuki/AkizukiLinearInterpolation.jl

In [2]:
#Pkg.rm("AkizukiLinearInterpolation")

In [3]:
#Pkg.clone("https://github.com/4kizuki/AkizukiLinearInterpolation.jl")

In [4]:
using AkizukiLinearInterpolation

In [5]:
grid = [1, 2]
vals = [2, 0]
f = my_lin_interp( grid, vals )
f(1.25)


Out[5]:
1.5

In [6]:
Pkg.test( "AkizukiLinearInterpolation" )
# Test Summary:                | Pass  Total
# Testing linear interporation |   13     13


INFO: Testing AkizukiLinearInterpolation
INFO: AkizukiLinearInterpolation tests passed

In [7]:
using Plots


WARNING: using Plots.grid in module Main conflicts with an existing identifier.

In [8]:
plotlyjs()


Plotly javascript loaded.

To load again call

init_notebook(true)

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

In [9]:
x = -7:7 
y = sin.(x)

xf = -7:0.1:7
plot(xf, sin.(xf), label="sine function")
scatter!(x, y, label="sampled data", markersize=4)


Out[9]:

In [10]:
li = my_lin_interp(x, y)
y_linear_qe = li.(xf)       # evaluate at multiple points

plot(xf, y_linear_qe, label="linear")
scatter!(x, y, label="sampled data", markersize=4)


Out[10]: