gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/randist.lua
diff options
context:
space:
mode:
Diffstat (limited to 'randist.lua')
-rw-r--r--randist.lua 23
1 files changed, 23 insertions, 0 deletions
diff --git a/randist.lua b/randist.lua
new file mode 100644
index 00000000..0a1c71d2
--- /dev/null
+++ b/randist.lua
@@ -0,0 +1,23 @@
+
+local gsl = require 'gsl'
+
+local format, match = string.format, string.match
+
+randist = {}
+
+local nmap = {pdf = 'ran', P = 'cdf', Q = 'cdf', Pinv = 'cdf', Qinv = 'cdf'}
+
+local function randist_index(t, k)
+ local name, suffix = match(k, '([%w_]+)_([%a]+)')
+ local namespace = nmap[suffix]
+ if name and suffix and namespace then
+ local gsl_name = format('gsl_%s_%s_%s', namespace, name, suffix)
+ return gsl[gsl_name]
+ end
+end
+
+local mt = { __index = randist_index }
+
+setmetatable(randist, mt)
+
+return randist
generated by cgit v1.2.3 (git 2.46.0) at 2025年10月03日 07:50:56 +0000

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