From cc77d7ccc034aecba64278e43112a61cf8c7f12c Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 2 Nov 2024 22:24:01 +0100 Subject: Calculate delta bar IoC for 2-124 long periods --- ioc.lua | 54 ++---------------------------------------------------- 1 file changed, 2 insertions(+), 52 deletions(-) (limited to 'ioc.lua') diff --git a/ioc.lua b/ioc.lua index 51c99e2..41e3d87 100755 --- a/ioc.lua +++ b/ioc.lua @@ -1,62 +1,12 @@ #!/usr/bin/env lua local eyes = require "eyes" local reading = require "reading" - - -local function fmt (float) - return string.format("%.5f", float) -end - - -local function stats (name, parent) - return { - name=name, - parent=parent, - letters=0, - length=0, - counts={}, - - add = function (self, value) - local current = self.counts[value] or 0 - if current == 0 then - self.letters = self.letters + 1 - end - self.length = self.length + 1 - self.counts[value] = current + 1 - end, - - ioc = function (self, letters) - letters = letters or self.letters - local subtotal = 0 - for _, count in pairs(self.counts) do - subtotal = subtotal + count * (count - 1) - end - return subtotal / (self.length * (self.length - 1) / letters) - end, - - dump = function (self) - local letters = (self.parent or {}).letters - io.write(name, "\t", self.length, "\t", self.letters, "\t", fmt(self:ioc(letters))) - if letters then - io.write("\t", fmt(self:ioc())) - end - print() - end - } -end - - +local stats = require "stats" local global = stats"global" -local lokals = {} for index, message in ipairs(eyes) do - local lokal = stats("#"..index, global) + local lokal = global:sub("#"..index) for _, value in reading.values(message) do - global:add(value) lokal:add(value) end - table.insert(lokals, lokal) -- Global is incomplete, can't dump yet. end global:dump() -for _, lokal in ipairs(lokals) do - lokal:dump() -end -- cgit v1.1