-
Notifications
You must be signed in to change notification settings - Fork 0
/
doska.ml
58 lines (47 loc) · 1.78 KB
/
doska.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
open Common
open Getopt
let length' = ref true
let minDays' = ref (Some 7)
let minCap' = ref 1e-35
let mark' = ref ""
let prefix' = ref "cstau"
let outdir' = ref (Some !prefix')
let specs =
[
('l',"length",(set length' (not !length')),None);
(noshort,"prefix",None,Some (fun x -> prefix' := x));
(noshort,"outdir",None,Some (fun x -> outdir' := Some x));
(noshort,"nodir", (set outdir' None), None);
('k',"mark",None,Some (fun x -> mark' := x))
]
let () =
let args = getOptArgs specs in
let prefix, outdir, mark =
!prefix', !outdir', !mark' in
let length, minDays, minCap =
!length', !minDays', !minCap' in
let dcapsName,dskewsName,outdir =
match args with
| dcapsName::dskewsName::outdir::restArgs -> dcapsName,dskewsName,Some outdir
| dcapsName::dskewsName::restArgs -> dcapsName,dskewsName,outdir
| _ -> failwith "usage: doska dcapsName dskewsName [outdir]"
in
let baseName = cutPathZ dskewsName in
let saveName = sprintf "%s-%s%s" prefix mark baseName |> mayPrependDir outdir in
leprintfln begin "reading dcaps from %s, dskews from %s\n"^^
"saving Kendall's Tau per day as a whole in %s,\n"^^
"%susing length in compareSkew" end
dcapsName dskewsName saveName (if length then "" else "not ");
let dcaps: user_day_reals = loadData dcapsName in
let sort = true in
let day_user_caps =
match minDays with
| Some md -> begin
leprintfln "maturizing capitals younger than %d days to %e" md minCap;
Dcaps.mature_day_user_caps md minCap ~sort dcaps
end
| _ -> Skew.day_user_caps ~sort dcaps in
let dskews: dskews = loadData dskewsName in
let cstau : float array = Skew_c.kendall_tau_days ~length day_user_caps dskews in
mayMkDir outdir;
saveData cstau saveName