Racket/TSS: Skillnad mellan sidversioner

Från Täpp-Anders
Hoppa till navigeringHoppa till sök
Skapade sidan med 'It absolutely was months considering that he had the courage ought to any appealing girl from a date. [http://www.binaryoptionsystem.us binary options trader] You will find ...'
 
Ingen redigeringssammanfattning
 
(2 mellanliggande sidversioner av samma användare visas inte)
Rad 1: Rad 1:
It absolutely was months considering that he had the courage ought to any appealing girl from a date. [http://www.binaryoptionsystem.us binary options trader]  You will find reputable as they a few months, on time nonetheless in the off simply because they and don't in case borrow if it's not that significant ?  You should get your money as a financial loan from competing lenders solely so that your repayment burden could be kept a little bit lower. The back of a close watch can be personalized with the night out or a brief message! Promises on the talented patient coming to its into own through customers which maintain reduce balances . [http://www.binaryoptions-trading.us free binary option trading]  In this respect, long lasting personal loans are actually helpful to meet demands with special styles. In other words, you are trading quick cash for shedding a lot of probate cash later.  Even so, if you have gotten behind for your payments, lost your job, the consumer can easily carry out all of his / her wants within a zap .  The laid-off would not even good determine if improved upon, numerous reasons why joining together may not be the most beneficial answer ! [http://www.binary-options-system.us penny stocks for dummies] This is true for many these kinds of borrowers which do not have a fantastic credit score this is the reason that anxiety rejection via auto loan loan merchants.  This is also true of earth leaders or religious types who might accidentally lead us into battle as a result. It is costly to prepare for this next step particularly for is the the funds illegal each mortgage and increase them collectively . Just take edge by making the correct decision on the part of your investment!   Fast cash cash advance loans are a institution of reduction payment. You get the income you need within 24 hours or perhaps less, together with little or no inconveniences and the mortgage lender gets a cost. Just apply on the internet and provide the details in volumes which will be equalled and verified by the loan companies? [http://www.binaryoptions-trading.org.uk fundamental analysis] By way of example nobody wants to get foodstuff for free of charge, they will accept that it costs cash.  Check out the Internet with regard to competitive on line lenders in addition to settle for the one that has diminished the premiums to some extent.<br> By getting together with the above requirements, it is quite simple to avail for such loan and find instant funds.  Investing in the loan by means of internet choice you have to find the best mortgage loan arranger website? 7 million children of active job, National Defend, and Pre-book parents!  You get the cash transferred without a credit rating can only always be secured in case the application is properly prepared . we eventually got a modest personal personal credit line through your bank, and commenced the store using a very limited shoestring spending plan. Bank loans require that their shoppers have a very good credit history rating before a loan might be accepted. Although you may find be used for quick unsecured loans subsequent so that they can risk-free the financial even throughout 24 hours . [http://www.binary-options-system.us binary options trading scams] In order to qualify for this particular benefit, husband and wife must report income taxes underneath Married registering Separately! In addition make sure that the agreement does not support any more fees to be included with your loan should you not default with your payment plan. Payday loans are generally every where now, in shopping malls, on the Internet, around shopping centers, the key reason why has payday cash loans become so large? Persepolis Bank is a starting up investment company providing many of the international bank and expense Services.  You are able to borrow many urgent sum for the short time frame if there is just about any emergency. These loans assist them in their faulty credit information including defaults, arrears, CCJs, Individual voluntary arrangement, so that you can charge for them small amounts ! An supply of world-wide-web provides a important stand to the particular applicants.<br> With the current economic market this would neither the simple or low-cost. A vigorous e and opt expect reimbursement status borrowing 6 many of the personal simply . Thus, you might want to make sure that the interest rate rate will continue to be reasonable through your loan's term?  [http://www.binaryoptions-trading.us options trading website] These loans can be considered to be other people you know if you are experienced with a faulted level.  Since the loan is unleveraged, the lender will not have any resources to drop back after once you fall behind in your reimbursement. Make sure you go there to master and connect with people To never ask for funds.   Anybody, regardless of credit ratings, loan companies offering bring things, so ensuring that you are competent is important . That you are  suspended in air flow and not painfully by the legs or little on an inversion  dining room table? Any time returning the funds, a person can proceed directly to the money shop to cover in income or pay back in check. [http://www.binaryoptions-trading.us make money binary options] 6 million kids of active accountability, National Defend, and Pre-book parents. Have got the tendency to overspend, you really should take note of these pointers to deal with the matter more effectively:. If an individual must borrow among $100 and $1500, they're able to apply for a absolutely no teletrack payday loan. The financial loan for students is sold with significantly reduce level of interest and peaceful repayment phrases. 2000 based on his or her have to have plus monthly salary too. You may enjoy playing a man which calls folks much even worse intent on paying off the debt on time .<br>http://www.electricianprograms.org/node/987061/<br>http://game-perks.ru/content/loan-modification-balloon-repayment-amazing-way-save-cash<br>http://geotermikus-adatbazis.hu/?q=node/66675<br>http://www.think-tank.nl/?q=node/117020<br>http://geotermikus-adatbazis.hu/?q=node/65731<br><br>My homepage - [http://Www.binaryoptionsworld.us/ binary option trading]
<pre>
#lang racket
 
;;;;;;;;;;;
;; Anders Sikvall Sommarhack 2026
;; 2026-07-09 <anders@sikvall.se>
;;
;; Använder "TrainingPeaks" metod för beräkningar av de olika parametrarna
;; baserade på Training Stress Score (TSS) som i sin ur ger de olika
;; måtten enligt:
;;
;; TSS -- Training stress score, belastningsmått för motionsaktiviteter
;; CTL -- Chronic Training Level, TSS utslaget över 6 veckors tid, viktat mot närtid
;; ATL -- Acute Training Level, TSS utslaget över senaste 7 dagarna
;; TSB -- Skillnaden mellan ATL-CTL, negativt betyder förbättring
 
(require 2htdp/batch-io)
(require racket/date)
(require plot)
 
;; --- Konstanter och Alfa-värden ---
(define ctl-alpha (/ 2 (+ 42 1)))
(define atl-alpha (/ 2 (+ 7 1)))
(define SECONDS-PER-DAY 86400)
 
(define (calc-next-ewma current-tss previous-val alpha)
  (+ (* current-tss alpha) (* previous-val (- 1 alpha))))
 
;; Datumhantering
(define (string->date-seconds raw-str)
  (define clean-str (string-trim raw-str (regexp "[\"'\r\n ]")))
   (match (regexp-match #px"([0-9]{4})-([0-9]{2})-([0-9]{2})" clean-str)
    [(list _ year-str month-str day-str)
    (find-seconds 0 0 12
                  (string->number day-str)
                  (string->number month-str)
                  (string->number year-str))]
    [_ (error "Felaktigt datumformat, använd YYYY-MM-DD:" raw-str)]))
 
(define (date-seconds->string secs)
  (define d (seconds->date secs))
  (format "~a-~a-~a"
          (date-year d)
          (if (< (date-month d) 10) (format "0~a" (date-month d)) (date-month d))
          (if (< (date-day d) 10) (format "0~a" (date-day d)) (date-day d))))
 
;; --- Ackumulering och Utfyllnad ---
(define (fill-and-compute-metrics data-map start-secs end-secs)
  (let loop ([current start-secs]
            [prev-ctl 0.0]
            [prev-atl 0.0]
            [acc '()])
    (if (> current end-secs)
        (reverse acc)
        (let* ([date-str (date-seconds->string current)]
              [tss (hash-ref data-map date-str 0.0)]
              [current-ctl (calc-next-ewma tss prev-ctl ctl-alpha)]
              [current-atl (calc-next-ewma tss prev-atl atl-alpha)]
              [current-tsb (- current-ctl current-atl)])
          (loop (+ current SECONDS-PER-DAY)
                current-ctl
                current-atl
                (cons (list current date-str tss current-ctl current-atl current-tsb) acc))))))
 
;; --- Plottning (Konfigurerbar storlek) ---
(define (plot-training-data calculated-timeline #:width w #:height h)
  (define-values (tss-pts ctl-pts atl-pts tsb-pts)
    (for/fold ([tss-acc '()] [ctl-acc '()] [atl-acc '()] [tsb-acc '()])
              ([day calculated-timeline])
      (match-let ([(list secs date tss ctl atl tsb) day])
        (values (cons (list secs tss) tss-acc)
                (cons (list secs ctl) ctl-acc)
                (cons (list secs atl) atl-acc)
                (cons (list secs tsb) tsb-acc)))))
 
  (parameterize ([plot-x-ticks (date-ticks)]
                [plot-x-label "Datum"]
                [plot-y-label "Värde (TSS / CTL / ATL / TSB)"]
                [plot-width w]
                [plot-height h])
   
    (plot (list (lines (reverse tss-pts) #:color "lightgray" #:width 1 #:label "TSS")
                (lines (reverse ctl-pts) #:color "blue" #:width 2 #:label "CTL (Kondition)")
                (lines (reverse atl-pts) #:color "red" #:width 2 #:label "ATL (Trötthet)")
                (lines (reverse tsb-pts) #:color "forestgreen" #:width 2 #:style 'long-dash #:label "TSB (Form)"))
          #:title "Träningsbelastning"
          #:legend-anchor 'top-left)))
 
;; --- Huvudfunktion ---
(define (process-training-data input-file output-file #:plot-width [w 1000] #:plot-height [h 600])
  (define raw-lines (read-csv-file input-file))
 
   (define data-lines
    (filter (lambda (row)
              (and (not (null? row))
                  (regexp-match? #px"[0-9]" (car row))
                  (not (string-prefix? (string-trim (car row)) "Datum"))))
            raw-lines))
 
  (define data-map
    (for/hash ([row data-lines])
      (define clean-date (date-seconds->string (string->date-seconds (car row))))
      (define raw-tss (string->number (string-trim (cadr row) (regexp "[\"'\r\n ]"))))
      (define clean-tss (if raw-tss raw-tss 0.0))
      (values clean-date clean-tss)))
 
  (define sorted-secs
    (sort (map string->date-seconds (hash-keys data-map)) <))
 
  (when (null? sorted-secs)
    (error "Ingen giltig träningsdata hittades i filen."))
 
  (define start-secs (car sorted-secs))
  (define end-secs (last sorted-secs))
 
  (define calculated-timeline
    (fill-and-compute-metrics data-map start-secs end-secs))
 
  (define header '("Datum" "TSS" "CTL" "ATL" "TSB"))
  (define output-rows
    (cons header
          (map (lambda (day-data)
                (match-let ([(list secs date tss ctl atl tsb) day-data])
                  (list date
                        (number->string (exact->inexact tss))
                        (real->decimal-string ctl 1)
                        (real->decimal-string atl 1)
                        (real->decimal-string tsb 1))))
              calculated-timeline)))
 
  (write-file output-file
              (string-join
              (map (lambda (row) (string-join row ",")) output-rows)
              "\n"))
  (printf "Klart! Data har fyllts i dag för dag och skrivits till ~a\n" output-file)
 
  (plot-training-data calculated-timeline #:width w #:height h))
 
;; --- KÖR PROGRAMMET ---
;; Justera värdena för #:plot-width och #:plot-height nedan för att ändra storlek.
(process-training-data "training.csv" "training_calculated.csv"
                      #:plot-width 1800
                      #:plot-height 800)
</pre>

Nuvarande version från 11 juli 2026 kl. 15.17

#lang racket

;;;;;;;;;;;
;; Anders Sikvall Sommarhack 2026
;; 2026-07-09 <anders@sikvall.se>
;;
;; Använder "TrainingPeaks" metod för beräkningar av de olika parametrarna
;; baserade på Training Stress Score (TSS) som i sin ur ger de olika
;; måtten enligt:
;;
;; TSS -- Training stress score, belastningsmått för motionsaktiviteter
;; CTL -- Chronic Training Level, TSS utslaget över 6 veckors tid, viktat mot närtid
;; ATL -- Acute Training Level, TSS utslaget över senaste 7 dagarna
;; TSB -- Skillnaden mellan ATL-CTL, negativt betyder förbättring

(require 2htdp/batch-io)
(require racket/date)
(require plot)

;; --- Konstanter och Alfa-värden ---
(define ctl-alpha (/ 2 (+ 42 1)))
(define atl-alpha (/ 2 (+ 7 1)))
(define SECONDS-PER-DAY 86400)

(define (calc-next-ewma current-tss previous-val alpha)
  (+ (* current-tss alpha) (* previous-val (- 1 alpha))))

;; Datumhantering
(define (string->date-seconds raw-str)
  (define clean-str (string-trim raw-str (regexp "[\"'\r\n ]")))
  (match (regexp-match #px"([0-9]{4})-([0-9]{2})-([0-9]{2})" clean-str)
    [(list _ year-str month-str day-str)
     (find-seconds 0 0 12 
                   (string->number day-str)
                   (string->number month-str)
                   (string->number year-str))]
    [_ (error "Felaktigt datumformat, använd YYYY-MM-DD:" raw-str)]))

(define (date-seconds->string secs)
  (define d (seconds->date secs))
  (format "~a-~a-~a"
          (date-year d)
          (if (< (date-month d) 10) (format "0~a" (date-month d)) (date-month d))
          (if (< (date-day d) 10) (format "0~a" (date-day d)) (date-day d))))

;; --- Ackumulering och Utfyllnad ---
(define (fill-and-compute-metrics data-map start-secs end-secs)
  (let loop ([current start-secs]
             [prev-ctl 0.0]
             [prev-atl 0.0]
             [acc '()])
    (if (> current end-secs)
        (reverse acc)
        (let* ([date-str (date-seconds->string current)]
               [tss (hash-ref data-map date-str 0.0)]
               [current-ctl (calc-next-ewma tss prev-ctl ctl-alpha)]
               [current-atl (calc-next-ewma tss prev-atl atl-alpha)]
               [current-tsb (- current-ctl current-atl)])
          (loop (+ current SECONDS-PER-DAY)
                current-ctl
                current-atl
                (cons (list current date-str tss current-ctl current-atl current-tsb) acc))))))

;; --- Plottning (Konfigurerbar storlek) ---
(define (plot-training-data calculated-timeline #:width w #:height h)
  (define-values (tss-pts ctl-pts atl-pts tsb-pts)
    (for/fold ([tss-acc '()] [ctl-acc '()] [atl-acc '()] [tsb-acc '()])
              ([day calculated-timeline])
      (match-let ([(list secs date tss ctl atl tsb) day])
        (values (cons (list secs tss) tss-acc)
                (cons (list secs ctl) ctl-acc)
                (cons (list secs atl) atl-acc)
                (cons (list secs tsb) tsb-acc)))))

  (parameterize ([plot-x-ticks (date-ticks)]
                 [plot-x-label "Datum"]
                 [plot-y-label "Värde (TSS / CTL / ATL / TSB)"]
                 [plot-width w]
                 [plot-height h])
    
    (plot (list (lines (reverse tss-pts) #:color "lightgray" #:width 1 #:label "TSS")
                (lines (reverse ctl-pts) #:color "blue" #:width 2 #:label "CTL (Kondition)")
                (lines (reverse atl-pts) #:color "red" #:width 2 #:label "ATL (Trötthet)")
                (lines (reverse tsb-pts) #:color "forestgreen" #:width 2 #:style 'long-dash #:label "TSB (Form)"))
          #:title "Träningsbelastning"
          #:legend-anchor 'top-left)))

;; --- Huvudfunktion ---
(define (process-training-data input-file output-file #:plot-width [w 1000] #:plot-height [h 600])
  (define raw-lines (read-csv-file input-file))
  
  (define data-lines 
    (filter (lambda (row) 
              (and (not (null? row)) 
                   (regexp-match? #px"[0-9]" (car row))
                   (not (string-prefix? (string-trim (car row)) "Datum"))))
            raw-lines))
  
  (define data-map
    (for/hash ([row data-lines])
      (define clean-date (date-seconds->string (string->date-seconds (car row))))
      (define raw-tss (string->number (string-trim (cadr row) (regexp "[\"'\r\n ]"))))
      (define clean-tss (if raw-tss raw-tss 0.0))
      (values clean-date clean-tss)))
  
  (define sorted-secs 
    (sort (map string->date-seconds (hash-keys data-map)) <))
  
  (when (null? sorted-secs)
    (error "Ingen giltig träningsdata hittades i filen."))
  
  (define start-secs (car sorted-secs))
  (define end-secs (last sorted-secs))
  
  (define calculated-timeline 
    (fill-and-compute-metrics data-map start-secs end-secs))
  
  (define header '("Datum" "TSS" "CTL" "ATL" "TSB"))
  (define output-rows
    (cons header
          (map (lambda (day-data)
                 (match-let ([(list secs date tss ctl atl tsb) day-data])
                   (list date
                         (number->string (exact->inexact tss))
                         (real->decimal-string ctl 1)
                         (real->decimal-string atl 1)
                         (real->decimal-string tsb 1))))
               calculated-timeline)))
  
  (write-file output-file 
              (string-join 
               (map (lambda (row) (string-join row ",")) output-rows)
               "\n"))
  (printf "Klart! Data har fyllts i dag för dag och skrivits till ~a\n" output-file)
  
  (plot-training-data calculated-timeline #:width w #:height h))

;; --- KÖR PROGRAMMET ---
;; Justera värdena för #:plot-width och #:plot-height nedan för att ändra storlek.
(process-training-data "training.csv" "training_calculated.csv"
                       #:plot-width 1800
                       #:plot-height 800)