X-Received: by 10.159.34.39 with SMTP id 36mr6561819uad.4.1461778717521; Wed, 27 Apr 2016 10:38:37 -0700 (PDT) X-Received: by 10.50.56.146 with SMTP id a18mr493955igq.3.1461778717369; Wed, 27 Apr 2016 10:38:37 -0700 (PDT) Path: csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!7no6534653qgj.0!news-out.google.com!uv8ni38igb.0!nntp.google.com!sq19no1562592igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.graphics.apps.gnuplot Date: Wed, 27 Apr 2016 10:38:37 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=142.90.101.112; posting-account=kySdhwoAAABMLr3RTV7ADVUi8CcCu6NT NNTP-Posting-Host: 142.90.101.112 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Gaussian fit - Singular matrix in Invert_RtR From: Andrew Finlay Injection-Date: Wed, 27 Apr 2016 17:38:37 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Received-Bytes: 2940 X-Received-Body-CRC: 2620394978 Xref: csiph.com comp.graphics.apps.gnuplot:3312 Hello, I'm trying to write code to automatically fit binned simulation data with a Gaussian function, but I'm getting a "Singular matrix in Invert_RtR" error when performing the fit. I'm currently using gnuplot version 5.0.3 on Windows 8. Code and data are attached below. Any help / guidance would be much appreciated. Thanks. gnuplot code: reset unset key set xlabel "Time of Flight" set ylabel "Counts" A = 218.0 Mean = 3561.978563 StdDev = 0.008026 f(x) = A*exp(-(x-Mean)**2/(2*StdDev**2)) set fit errorvariables fit [3561.851:3562.008] f(x) "histoTest.txt" u 1:2:3 yerror via A,Mean,StdDev plot "histoTest.txt" u 1:2:3 w yerrorbars, f(x) Contents of my data file (please note, the error values are the square root of the counts, but when this would be 0, I chose a value of 0.0001 to try to avoid issues): # ToF Count Error 3561.851 1 1.000000 3561.855 0 0.000100 3561.859 0 0.000100 3561.863 0 0.000100 3561.867 0 0.000100 3561.871 0 0.000100 3561.875 0 0.000100 3561.878 0 0.000100 3561.882 0 0.000100 3561.886 0 0.000100 3561.890 1 1.000000 3561.894 2 1.414214 3561.898 0 0.000100 3561.902 2 1.414214 3561.906 3 1.732051 3561.910 2 1.414214 3561.914 2 1.414214 3561.918 3 1.732051 3561.922 6 2.449490 3561.926 6 2.449490 3561.930 4 2.000000 3561.933 10 3.162278 3561.937 8 2.828427 3561.941 13 3.605551 3561.945 10 3.162278 3561.949 11 3.316625 3561.953 26 5.099020 3561.957 24 4.898979 3561.961 41 6.403124 3561.965 55 7.416198 3561.969 58 7.615773 3561.973 110 10.488088 3561.977 218 14.764823 3561.981 170 13.038405 3561.984 49 7.000000 3561.988 17 4.123106 3561.992 3 1.732051 3561.996 1 1.000000 3562.000 3 1.732051 3562.004 3 1.732051 3562.008 0 0.000100