Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NaN results and internal error in optimizer #10

Open
SV-97 opened this issue Oct 27, 2024 · 0 comments
Open

NaN results and internal error in optimizer #10

SV-97 opened this issue Oct 27, 2024 · 0 comments

Comments

@SV-97
Copy link

SV-97 commented Oct 27, 2024

I just ran DeCAFS with default arguments on a data sample and found that the output contains mostly NaNs. The input sample consists of 150 quite "normal" floats (no extremely small or large values, no NaN, no inf).

Reproduction:

library(DeCAFS)

y <- c(0.007487091243194955, 0.11791772771897412, 0.274858774774672, 0.32048047282650544, 0.3757456660237557, 0.566730137881182, 0.6468999628291104, 0.6825335929668119, 0.6684561104986123, 0.6742599957935859, 0.7123965269877737, 0.789119111739368, 0.7754592668321887, 0.9455229561156615, 0.8888850229080866, 0.9579045591010575, 0.9684453261535323, 0.9841466930118666, 1.01946205123237, 1.045175796792769, 0.981351126931916, 1.054297252524191, 0.942791676871981, 0.993005029590164, 1.0180014152473884, 0.9773316292505307, 0.9370515582015042, 0.9287021264216976, 0.9537520897393428, 0.9893110549878226, 0.9244673162832447, 0.9326054143717626, 0.8343611130380136, 0.8470182924547867, 0.8261301563301607, 0.7793719088575547, 0.3180211446782288, 0.31175824054646195, 0.3262753637162709, 0.2604205289329914, 0.01116637952088971, 0.4460261887369531, 0.4376237711891152, 0.40939557003502136, 0.38355278151646516, 0.3546338592731786, 0.13139142282684407, 0.1564255346584222, 0.14793892322342267, 0.12304102096857022, 0.07136721501014419, -0.011492751541630042, 0.04752713244714551, 0.07963591318517446, -0.022611757851454417, 0.0532148617806642, 0.053020104207421204, 0.058268629892130434, -0.04286326365559641, -0.019304572629339233, -0.011617545351878995, -0.04855446191674602, 0.09363161575240134, -0.020188874136647012, 0.01669865574916081, -0.011731061835822452, 0.08055727879776026, 0.06779383612941671, 0.05530644154140523, -0.08341616114978281, 0.031224197872941218, 0.06546575582720798, 0.08360276013086411, 0.015998939168694153, 0.14560395375002605, -0.002525927877456216, 0.04891629102073212, 0.25296946817818194, 0.2330548078002823, 0.3683625343556855, 0.48797658559001716, 0.4478107015692193, 0.5049142223839364, 0.47609272107494005, 0.5485907170173352, 0.6753893937196748, 0.722192989992027, 0.14311353260324516, 0.11112483988056437, 0.3628065796077881, 0.3229085631895193, 0.44015585731060797, 0.3629064849762885, 0.3630253898732863, 0.6138177453092869, 0.6979561855502128, 0.6614044981461945, 0.6769893756120073, 0.6904405919697462, 0.7483956350476936, 0.9744134604476808, 1.0026648371212223, 0.9886874859073326, 0.9355764088164243, 1.012842682176877, 0.6792236359711198, 0.6029048140844963, 0.6531411971377318, 0.25848459521735445, 0.9482914438926076, 0.9016693943091647, 0.9391852465583588, 0.9443951812436269, 0.9600693785169708, 0.992180570176749, 0.9266091472567773, 1.0577838405262177, 1.0307100143601928, 1.0382449383276637, 1.0525269463466438, 1.0002502423574253, 0.9872844193998384, 0.8009263038737743, 0.65125631418937, 0.5551140437855852, 0.5168431042571614, 0.2773549149869592, 0.2174255747559068, 0.016568715911897434, 0.9127055613108187, 0.8930462624084491, 0.9320777447604038, 0.9221333560289896, 0.8590934257726004, 0.7491357494384808, 0.7508279518141973, 0.6777549103073315, 0.6633019713402686, 0.3425453035598096, 0.459988930413731, 0.4074590298163433, 0.3444540185022145, 0.3302176201837615, 0.3019037768284888, 0.2002920314026595, 0.13132875882196646, 0.03320156243391202, 0.09465993597838829, -0.020184327783061555, 0.07033136127845799)

res <- DeCAFS(y)
res # contains a bunch of NaN

and corresponding output for this:

$changepoints
  [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18
 [19]  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36
 [37]  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54
 [55]  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72
 [73]  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90
 [91]  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108
[109] 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
[127] 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
[145] 145 146 147 148 149

$signal
  [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
 [19] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
 [37] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
 [55] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
 [73] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
 [91] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
[109] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
[127] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
[145] NaN NaN NaN NaN NaN NaN

$costFunction
  tau    l   u   a   b   c
1   1 -Inf Inf NaN NaN NaN

$modelParameters
$modelParameters$sdEta
[1] NaN

$modelParameters$sdNu
[1] 0.1509451

$modelParameters$phi
         
0.850643 


$data
  [1]  0.007487091  0.117917728  0.274858775  0.320480473  0.375745666
  [6]  0.566730138  0.646899963  0.682533593  0.668456110  0.674259996
 [11]  0.712396527  0.789119112  0.775459267  0.945522956  0.888885023
 [16]  0.957904559  0.968445326  0.984146693  1.019462051  1.045175797
 [21]  0.981351127  1.054297253  0.942791677  0.993005030  1.018001415
 [26]  0.977331629  0.937051558  0.928702126  0.953752090  0.989311055
 [31]  0.924467316  0.932605414  0.834361113  0.847018292  0.826130156
 [36]  0.779371909  0.318021145  0.311758241  0.326275364  0.260420529
 [41]  0.011166380  0.446026189  0.437623771  0.409395570  0.383552782
 [46]  0.354633859  0.131391423  0.156425535  0.147938923  0.123041021
 [51]  0.071367215 -0.011492752  0.047527132  0.079635913 -0.022611758
 [56]  0.053214862  0.053020104  0.058268630 -0.042863264 -0.019304573
 [61] -0.011617545 -0.048554462  0.093631616 -0.020188874  0.016698656
 [66] -0.011731062  0.080557279  0.067793836  0.055306442 -0.083416161
 [71]  0.031224198  0.065465756  0.083602760  0.015998939  0.145603954
 [76] -0.002525928  0.048916291  0.252969468  0.233054808  0.368362534
 [81]  0.487976586  0.447810702  0.504914222  0.476092721  0.548590717
 [86]  0.675389394  0.722192990  0.143113533  0.111124840  0.362806580
 [91]  0.322908563  0.440155857  0.362906485  0.363025390  0.613817745
 [96]  0.697956186  0.661404498  0.676989376  0.690440592  0.748395635
[101]  0.974413460  1.002664837  0.988687486  0.935576409  1.012842682
[106]  0.679223636  0.602904814  0.653141197  0.258484595  0.948291444
[111]  0.901669394  0.939185247  0.944395181  0.960069379  0.992180570
[116]  0.926609147  1.057783841  1.030710014  1.038244938  1.052526946
[121]  1.000250242  0.987284419  0.800926304  0.651256314  0.555114044
[126]  0.516843104  0.277354915  0.217425575  0.016568716  0.912705561
[131]  0.893046262  0.932077745  0.922133356  0.859093426  0.749135749
[136]  0.750827952  0.677754910  0.663301971  0.342545304  0.459988930
[141]  0.407459030  0.344454019  0.330217620  0.301903777  0.200292031
[146]  0.131328759  0.033201562  0.094659936 -0.020184328  0.070331361

attr(,"class")
[1] "DeCAFSout" "list"    

While trying to reduce this data to a minimal reproducing example I further encountered an internal error:

Error in optim(par = start, .MoMCost, lower = c(phiLower, 0.001, 0), upper = c(phiUpper,  : 
  L-BFGS-B needs finite values of 'fn'

The reproducing example for this is:

library(DeCAFS)

y <- c(0.007487091243194955, 0.11791772771897412, 0.274858774774672, 0.32048047282650544, 0.3757456660237557, 0.566730137881182, 0.6468999628291104, 0.6825335929668119, 0.6684561104986123, 0.6742599957935859, 0.7123965269877737, 0.789119111739368, 0.7754592668321887, 0.9455229561156615, 0.8888850229080866)

res <- DeCAFS(y)

I originally ran into this issue on a Fedora Silverblue system (Fedora 40, Kernel 6.10.12-200, running on x64 AMD 5900X) however a colleague was able to reproduce it on their non-linux machine as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant