gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2011年10月24日 13:31:19 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2011年10月24日 13:31:19 +0200
commitc0a06f4256181ad682daf21c4ad30dc74a74447c (patch)
tree2ea2829c86c071a0618bb042af0464d38b13acc5
parentbba69adf6f3a6303c38f46f4d0ba4b7cc7828c32 (diff)
downloadgsl-shell-c0a06f4256181ad682daf21c4ad30dc74a74447c.tar.gz
Add demo with linear fit examples
Diffstat
-rw-r--r--demo-init.lua 2
-rw-r--r--demos/linfit.lua (renamed from examples/linfit.lua)18
2 files changed, 15 insertions, 5 deletions
diff --git a/demo-init.lua b/demo-init.lua
index 8abfebe3..56087372 100644
--- a/demo-init.lua
+++ b/demo-init.lua
@@ -16,7 +16,7 @@ local function load_demo(name)
end
local demo_files = {
- 'fft', 'bspline', 'wave-particle', 'plot', 'fractals', 'ode', 'nlinfit', 'integ', 'anim'}
+ 'fft', 'bspline', 'wave-particle', 'plot', 'fractals', 'ode', 'nlinfit', 'integ', 'anim', 'linfit'}
for i, name in ipairs(demo_files) do
load_demo(name)
diff --git a/examples/linfit.lua b/demos/linfit.lua
index 69bb266c..55112036 100644
--- a/examples/linfit.lua
+++ b/demos/linfit.lua
@@ -2,7 +2,7 @@ use 'math'
use 'iter'
use 'num'
-function demo1()
+local function demo1()
local x0, x1, n = 0, 12.5, 32
local a, b = 0.55, -2.4
local xsmp = |i| (i-1)/(n-1) * x1
@@ -27,7 +27,7 @@ function demo1()
return p
end
-function demo2()
+local function demo2()
local order, x0, x1, n = 3, 0.0, 24.0, 96
local bess = |x| besselJ(order, x)
local xsmp = |i| x0 + (i-1)/(n-1) * (x1 - x0)
@@ -61,5 +61,15 @@ function demo2()
return p
end
-echo 'demo1() - examples of linear regression of (x, y) data'
-echo 'demo2() - examples of linear regression based on legendre polynomials'
+return {'Linear Fit', {
+ {
+ name= 'linfit1',
+ f = demo1,
+ description = 'Simple linear regression example'
+ },
+ {
+ name= 'linfit2',
+ f = demo2,
+ description = 'Complex example of a linear fit based on legendre polynomials'
+ },
+}}
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月30日 23:55:00 +0000

AltStyle によって変換されたページ (->オリジナル) /