Commit db8f1115 authored by CD's avatar CD
Browse files

Change to curve used for homeostatic-sleep function (time since last asleep)....

Change to curve used for homeostatic-sleep function (time since last asleep). Function now uses logistic curve
parent 39ea8cb6
......@@ -283,10 +283,13 @@
(* (AA-pred-error-arous-ratio aa) pred-error-factor)
0))))))
;;This function computes a factor to decay arousal slightly non-linearly (X^2) based
;;This function computes a factor to decay arousal non-linearly (logistic function with beta param) based
;; on how long it has been since the model has slept. By default, the function assumes
;; an arbitrary max amount of days awake of 4 before hitting a minimal value (0.0001)
;; The value output is in the range from 0.0001 to 1
;;Beta-Logistic function - 1/(1+(homArousal^r/(1-homArousal^r))^-beta)
;; r here tells us where on the x the y should be located
;; time_since_norm is defined as ((maxDays-timeSinceAsleep)/maxDays)
(defun compute-homeostatic-arousal-factor (&optional test)
(let* ((LA (if (cadar (car (get-phys-vals nil (list '("Status.LastAsleep")))))
(cadar (car (get-phys-vals nil (list '("Status.LastAsleep")))))
......@@ -298,10 +301,10 @@
(maxDays 4)
(timeSinceAsleep (- (read-from-string currT) (read-from-string LA))))
(if (and LA currT (> timeSinceAsleep 0))
(let ((homArousal (/ (- (expt (* maxDays 1440) 2) (expt timeSinceAsleep 2)) (expt (* maxDays 1440) 2))))
(let ((homArousal (/ (- (* maxDays 1440) timeSinceAsleep) (* maxDays 1440))))
(if (> homArousal 0)
(progn
(setf ret-arousal homArousal))))
(setf ret-arousal (/ 1 (+ 1 (expt (/ (expt homArousal r) (- 1 (expt homArousal r))) (* -1 beta))))))))
(setf ret-arousal 1))
(if test
(with-open-file
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment