commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r857558 [27/39] - in /websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3: ./ analysis/ analysis/differentiation/ analysis/interpolation/ complex/ dfp/ distribution/ distribution/fitting/ ex...
Date Sat, 06 Apr 2013 23:42:02 GMT
Modified: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/optim/nonlinear/vector/jacobian/LevenbergMarquardtOptimizerTest.html
==============================================================================
--- websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/optim/nonlinear/vector/jacobian/LevenbergMarquardtOptimizerTest.html (original)
+++ websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/optim/nonlinear/vector/jacobian/LevenbergMarquardtOptimizerTest.html Sat Apr  6 23:42:01 2013
@@ -26,384 +26,396 @@
 <FONT color="green">023</FONT>    import org.apache.commons.math3.optim.PointVectorValuePair;<a name="line.23"></a>
 <FONT color="green">024</FONT>    import org.apache.commons.math3.optim.InitialGuess;<a name="line.24"></a>
 <FONT color="green">025</FONT>    import org.apache.commons.math3.optim.MaxEval;<a name="line.25"></a>
-<FONT color="green">026</FONT>    import org.apache.commons.math3.optim.nonlinear.vector.Target;<a name="line.26"></a>
-<FONT color="green">027</FONT>    import org.apache.commons.math3.optim.nonlinear.vector.Weight;<a name="line.27"></a>
-<FONT color="green">028</FONT>    import org.apache.commons.math3.optim.nonlinear.vector.ModelFunction;<a name="line.28"></a>
-<FONT color="green">029</FONT>    import org.apache.commons.math3.optim.nonlinear.vector.ModelFunctionJacobian;<a name="line.29"></a>
-<FONT color="green">030</FONT>    import org.apache.commons.math3.analysis.MultivariateVectorFunction;<a name="line.30"></a>
-<FONT color="green">031</FONT>    import org.apache.commons.math3.analysis.MultivariateMatrixFunction;<a name="line.31"></a>
-<FONT color="green">032</FONT>    import org.apache.commons.math3.exception.ConvergenceException;<a name="line.32"></a>
-<FONT color="green">033</FONT>    import org.apache.commons.math3.exception.DimensionMismatchException;<a name="line.33"></a>
-<FONT color="green">034</FONT>    import org.apache.commons.math3.exception.TooManyEvaluationsException;<a name="line.34"></a>
-<FONT color="green">035</FONT>    import org.apache.commons.math3.geometry.euclidean.twod.Vector2D;<a name="line.35"></a>
-<FONT color="green">036</FONT>    import org.apache.commons.math3.linear.SingularMatrixException;<a name="line.36"></a>
-<FONT color="green">037</FONT>    import org.apache.commons.math3.util.FastMath;<a name="line.37"></a>
-<FONT color="green">038</FONT>    import org.apache.commons.math3.util.Precision;<a name="line.38"></a>
-<FONT color="green">039</FONT>    import org.junit.Assert;<a name="line.39"></a>
-<FONT color="green">040</FONT>    import org.junit.Test;<a name="line.40"></a>
-<FONT color="green">041</FONT>    import org.junit.Ignore;<a name="line.41"></a>
-<FONT color="green">042</FONT>    <a name="line.42"></a>
-<FONT color="green">043</FONT>    /**<a name="line.43"></a>
-<FONT color="green">044</FONT>     * &lt;p&gt;Some of the unit tests are re-implementations of the MINPACK &lt;a<a name="line.44"></a>
-<FONT color="green">045</FONT>     * href="http://www.netlib.org/minpack/ex/file17"&gt;file17&lt;/a&gt; and &lt;a<a name="line.45"></a>
-<FONT color="green">046</FONT>     * href="http://www.netlib.org/minpack/ex/file22"&gt;file22&lt;/a&gt; test files.<a name="line.46"></a>
-<FONT color="green">047</FONT>     * The redistribution policy for MINPACK is available &lt;a<a name="line.47"></a>
-<FONT color="green">048</FONT>     * href="http://www.netlib.org/minpack/disclaimer"&gt;here&lt;/a&gt;, for<a name="line.48"></a>
-<FONT color="green">049</FONT>     * convenience, it is reproduced below.&lt;/p&gt;<a name="line.49"></a>
-<FONT color="green">050</FONT>    <a name="line.50"></a>
-<FONT color="green">051</FONT>     * &lt;table border="0" width="80%" cellpadding="10" align="center" bgcolor="#E0E0E0"&gt;<a name="line.51"></a>
-<FONT color="green">052</FONT>     * &lt;tr&gt;&lt;td&gt;<a name="line.52"></a>
-<FONT color="green">053</FONT>     *    Minpack Copyright Notice (1999) University of Chicago.<a name="line.53"></a>
-<FONT color="green">054</FONT>     *    All rights reserved<a name="line.54"></a>
-<FONT color="green">055</FONT>     * &lt;/td&gt;&lt;/tr&gt;<a name="line.55"></a>
-<FONT color="green">056</FONT>     * &lt;tr&gt;&lt;td&gt;<a name="line.56"></a>
-<FONT color="green">057</FONT>     * Redistribution and use in source and binary forms, with or without<a name="line.57"></a>
-<FONT color="green">058</FONT>     * modification, are permitted provided that the following conditions<a name="line.58"></a>
-<FONT color="green">059</FONT>     * are met:<a name="line.59"></a>
-<FONT color="green">060</FONT>     * &lt;ol&gt;<a name="line.60"></a>
-<FONT color="green">061</FONT>     *  &lt;li&gt;Redistributions of source code must retain the above copyright<a name="line.61"></a>
-<FONT color="green">062</FONT>     *      notice, this list of conditions and the following disclaimer.&lt;/li&gt;<a name="line.62"></a>
-<FONT color="green">063</FONT>     * &lt;li&gt;Redistributions in binary form must reproduce the above<a name="line.63"></a>
-<FONT color="green">064</FONT>     *     copyright notice, this list of conditions and the following<a name="line.64"></a>
-<FONT color="green">065</FONT>     *     disclaimer in the documentation and/or other materials provided<a name="line.65"></a>
-<FONT color="green">066</FONT>     *     with the distribution.&lt;/li&gt;<a name="line.66"></a>
-<FONT color="green">067</FONT>     * &lt;li&gt;The end-user documentation included with the redistribution, if any,<a name="line.67"></a>
-<FONT color="green">068</FONT>     *     must include the following acknowledgment:<a name="line.68"></a>
-<FONT color="green">069</FONT>     *     &lt;code&gt;This product includes software developed by the University of<a name="line.69"></a>
-<FONT color="green">070</FONT>     *           Chicago, as Operator of Argonne National Laboratory.&lt;/code&gt;<a name="line.70"></a>
-<FONT color="green">071</FONT>     *     Alternately, this acknowledgment may appear in the software itself,<a name="line.71"></a>
-<FONT color="green">072</FONT>     *     if and wherever such third-party acknowledgments normally appear.&lt;/li&gt;<a name="line.72"></a>
-<FONT color="green">073</FONT>     * &lt;li&gt;&lt;strong&gt;WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS"<a name="line.73"></a>
-<FONT color="green">074</FONT>     *     WITHOUT WARRANTY OF ANY KIND. THE COPYRIGHT HOLDER, THE<a name="line.74"></a>
-<FONT color="green">075</FONT>     *     UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND<a name="line.75"></a>
-<FONT color="green">076</FONT>     *     THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES, EXPRESS OR<a name="line.76"></a>
-<FONT color="green">077</FONT>     *     IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES<a name="line.77"></a>
-<FONT color="green">078</FONT>     *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE<a name="line.78"></a>
-<FONT color="green">079</FONT>     *     OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY<a name="line.79"></a>
-<FONT color="green">080</FONT>     *     OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR<a name="line.80"></a>
-<FONT color="green">081</FONT>     *     USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE OF<a name="line.81"></a>
-<FONT color="green">082</FONT>     *     THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4)<a name="line.82"></a>
-<FONT color="green">083</FONT>     *     DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION<a name="line.83"></a>
-<FONT color="green">084</FONT>     *     UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL<a name="line.84"></a>
-<FONT color="green">085</FONT>     *     BE CORRECTED.&lt;/strong&gt;&lt;/li&gt;<a name="line.85"></a>
-<FONT color="green">086</FONT>     * &lt;li&gt;&lt;strong&gt;LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT<a name="line.86"></a>
-<FONT color="green">087</FONT>     *     HOLDER, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF<a name="line.87"></a>
-<FONT color="green">088</FONT>     *     ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT,<a name="line.88"></a>
-<FONT color="green">089</FONT>     *     INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF<a name="line.89"></a>
-<FONT color="green">090</FONT>     *     ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF<a name="line.90"></a>
-<FONT color="green">091</FONT>     *     PROFITS OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER<a name="line.91"></a>
-<FONT color="green">092</FONT>     *     SUCH LIABILITY IS ASSERTED ON THE BASIS OF CONTRACT, TORT<a name="line.92"></a>
-<FONT color="green">093</FONT>     *     (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE,<a name="line.93"></a>
-<FONT color="green">094</FONT>     *     EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE<a name="line.94"></a>
-<FONT color="green">095</FONT>     *     POSSIBILITY OF SUCH LOSS OR DAMAGES.&lt;/strong&gt;&lt;/li&gt;<a name="line.95"></a>
-<FONT color="green">096</FONT>     * &lt;ol&gt;&lt;/td&gt;&lt;/tr&gt;<a name="line.96"></a>
-<FONT color="green">097</FONT>     * &lt;/table&gt;<a name="line.97"></a>
-<FONT color="green">098</FONT>    <a name="line.98"></a>
-<FONT color="green">099</FONT>     * @author Argonne National Laboratory. MINPACK project. March 1980 (original fortran minpack tests)<a name="line.99"></a>
-<FONT color="green">100</FONT>     * @author Burton S. Garbow (original fortran minpack tests)<a name="line.100"></a>
-<FONT color="green">101</FONT>     * @author Kenneth E. Hillstrom (original fortran minpack tests)<a name="line.101"></a>
-<FONT color="green">102</FONT>     * @author Jorge J. More (original fortran minpack tests)<a name="line.102"></a>
-<FONT color="green">103</FONT>     * @author Luc Maisonobe (non-minpack tests and minpack tests Java translation)<a name="line.103"></a>
-<FONT color="green">104</FONT>     */<a name="line.104"></a>
-<FONT color="green">105</FONT>    public class LevenbergMarquardtOptimizerTest<a name="line.105"></a>
-<FONT color="green">106</FONT>        extends AbstractLeastSquaresOptimizerAbstractTest {<a name="line.106"></a>
-<FONT color="green">107</FONT>        @Override<a name="line.107"></a>
-<FONT color="green">108</FONT>        public AbstractLeastSquaresOptimizer createOptimizer() {<a name="line.108"></a>
-<FONT color="green">109</FONT>            return new LevenbergMarquardtOptimizer();<a name="line.109"></a>
-<FONT color="green">110</FONT>        }<a name="line.110"></a>
-<FONT color="green">111</FONT>    <a name="line.111"></a>
-<FONT color="green">112</FONT>        @Override<a name="line.112"></a>
-<FONT color="green">113</FONT>        @Test(expected=SingularMatrixException.class)<a name="line.113"></a>
-<FONT color="green">114</FONT>        public void testNonInvertible() {<a name="line.114"></a>
-<FONT color="green">115</FONT>            /*<a name="line.115"></a>
-<FONT color="green">116</FONT>             * Overrides the method from parent class, since the default singularity<a name="line.116"></a>
-<FONT color="green">117</FONT>             * threshold (1e-14) does not trigger the expected exception.<a name="line.117"></a>
-<FONT color="green">118</FONT>             */<a name="line.118"></a>
-<FONT color="green">119</FONT>            LinearProblem problem = new LinearProblem(new double[][] {<a name="line.119"></a>
-<FONT color="green">120</FONT>                    {  1, 2, -3 },<a name="line.120"></a>
-<FONT color="green">121</FONT>                    {  2, 1,  3 },<a name="line.121"></a>
-<FONT color="green">122</FONT>                    { -3, 0, -9 }<a name="line.122"></a>
-<FONT color="green">123</FONT>            }, new double[] { 1, 1, 1 });<a name="line.123"></a>
-<FONT color="green">124</FONT>    <a name="line.124"></a>
-<FONT color="green">125</FONT>            AbstractLeastSquaresOptimizer optimizer = createOptimizer();<a name="line.125"></a>
-<FONT color="green">126</FONT>            PointVectorValuePair optimum<a name="line.126"></a>
-<FONT color="green">127</FONT>                = optimizer.optimize(new MaxEval(100),<a name="line.127"></a>
-<FONT color="green">128</FONT>                                     problem.getModelFunction(),<a name="line.128"></a>
-<FONT color="green">129</FONT>                                     problem.getModelFunctionJacobian(),<a name="line.129"></a>
-<FONT color="green">130</FONT>                                     problem.getTarget(),<a name="line.130"></a>
-<FONT color="green">131</FONT>                                     new Weight(new double[] { 1, 1, 1 }),<a name="line.131"></a>
-<FONT color="green">132</FONT>                                     new InitialGuess(new double[] { 0, 0, 0 }));<a name="line.132"></a>
-<FONT color="green">133</FONT>            Assert.assertTrue(FastMath.sqrt(optimizer.getTargetSize()) * optimizer.getRMS() &gt; 0.6);<a name="line.133"></a>
-<FONT color="green">134</FONT>    <a name="line.134"></a>
-<FONT color="green">135</FONT>            optimizer.computeCovariances(optimum.getPoint(), 1.5e-14);<a name="line.135"></a>
-<FONT color="green">136</FONT>        }<a name="line.136"></a>
-<FONT color="green">137</FONT>    <a name="line.137"></a>
-<FONT color="green">138</FONT>        @Test<a name="line.138"></a>
-<FONT color="green">139</FONT>        public void testControlParameters() {<a name="line.139"></a>
-<FONT color="green">140</FONT>            CircleVectorial circle = new CircleVectorial();<a name="line.140"></a>
-<FONT color="green">141</FONT>            circle.addPoint( 30.0,  68.0);<a name="line.141"></a>
-<FONT color="green">142</FONT>            circle.addPoint( 50.0,  -6.0);<a name="line.142"></a>
-<FONT color="green">143</FONT>            circle.addPoint(110.0, -20.0);<a name="line.143"></a>
-<FONT color="green">144</FONT>            circle.addPoint( 35.0,  15.0);<a name="line.144"></a>
-<FONT color="green">145</FONT>            circle.addPoint( 45.0,  97.0);<a name="line.145"></a>
-<FONT color="green">146</FONT>            checkEstimate(circle.getModelFunction(),<a name="line.146"></a>
-<FONT color="green">147</FONT>                          circle.getModelFunctionJacobian(),<a name="line.147"></a>
-<FONT color="green">148</FONT>                          0.1, 10, 1.0e-14, 1.0e-16, 1.0e-10, false);<a name="line.148"></a>
-<FONT color="green">149</FONT>            checkEstimate(circle.getModelFunction(),<a name="line.149"></a>
-<FONT color="green">150</FONT>                          circle.getModelFunctionJacobian(),<a name="line.150"></a>
-<FONT color="green">151</FONT>                          0.1, 10, 1.0e-15, 1.0e-17, 1.0e-10, true);<a name="line.151"></a>
-<FONT color="green">152</FONT>            checkEstimate(circle.getModelFunction(),<a name="line.152"></a>
-<FONT color="green">153</FONT>                          circle.getModelFunctionJacobian(),<a name="line.153"></a>
-<FONT color="green">154</FONT>                          0.1,  5, 1.0e-15, 1.0e-16, 1.0e-10, true);<a name="line.154"></a>
-<FONT color="green">155</FONT>            circle.addPoint(300, -300);<a name="line.155"></a>
-<FONT color="green">156</FONT>            checkEstimate(circle.getModelFunction(),<a name="line.156"></a>
-<FONT color="green">157</FONT>                          circle.getModelFunctionJacobian(),<a name="line.157"></a>
-<FONT color="green">158</FONT>                          0.1, 20, 1.0e-18, 1.0e-16, 1.0e-10, true);<a name="line.158"></a>
-<FONT color="green">159</FONT>        }<a name="line.159"></a>
-<FONT color="green">160</FONT>    <a name="line.160"></a>
-<FONT color="green">161</FONT>        private void checkEstimate(ModelFunction problem,<a name="line.161"></a>
-<FONT color="green">162</FONT>                                   ModelFunctionJacobian problemJacobian,<a name="line.162"></a>
-<FONT color="green">163</FONT>                                   double initialStepBoundFactor, int maxCostEval,<a name="line.163"></a>
-<FONT color="green">164</FONT>                                   double costRelativeTolerance, double parRelativeTolerance,<a name="line.164"></a>
-<FONT color="green">165</FONT>                                   double orthoTolerance, boolean shouldFail) {<a name="line.165"></a>
-<FONT color="green">166</FONT>            try {<a name="line.166"></a>
-<FONT color="green">167</FONT>                LevenbergMarquardtOptimizer optimizer<a name="line.167"></a>
-<FONT color="green">168</FONT>                    = new LevenbergMarquardtOptimizer(initialStepBoundFactor,<a name="line.168"></a>
-<FONT color="green">169</FONT>                                                      costRelativeTolerance,<a name="line.169"></a>
-<FONT color="green">170</FONT>                                                      parRelativeTolerance,<a name="line.170"></a>
-<FONT color="green">171</FONT>                                                      orthoTolerance,<a name="line.171"></a>
-<FONT color="green">172</FONT>                                                      Precision.SAFE_MIN);<a name="line.172"></a>
-<FONT color="green">173</FONT>                optimizer.optimize(new MaxEval(maxCostEval),<a name="line.173"></a>
-<FONT color="green">174</FONT>                                   problem,<a name="line.174"></a>
-<FONT color="green">175</FONT>                                   problemJacobian,<a name="line.175"></a>
-<FONT color="green">176</FONT>                                   new Target(new double[] { 0, 0, 0, 0, 0 }),<a name="line.176"></a>
-<FONT color="green">177</FONT>                                   new Weight(new double[] { 1, 1, 1, 1, 1 }),<a name="line.177"></a>
-<FONT color="green">178</FONT>                                   new InitialGuess(new double[] { 98.680, 47.345 }));<a name="line.178"></a>
-<FONT color="green">179</FONT>                Assert.assertTrue(!shouldFail);<a name="line.179"></a>
-<FONT color="green">180</FONT>            } catch (DimensionMismatchException ee) {<a name="line.180"></a>
-<FONT color="green">181</FONT>                Assert.assertTrue(shouldFail);<a name="line.181"></a>
-<FONT color="green">182</FONT>            } catch (TooManyEvaluationsException ee) {<a name="line.182"></a>
-<FONT color="green">183</FONT>                Assert.assertTrue(shouldFail);<a name="line.183"></a>
-<FONT color="green">184</FONT>            }<a name="line.184"></a>
-<FONT color="green">185</FONT>        }<a name="line.185"></a>
-<FONT color="green">186</FONT>    <a name="line.186"></a>
-<FONT color="green">187</FONT>        /**<a name="line.187"></a>
-<FONT color="green">188</FONT>         * Non-linear test case: fitting of decay curve (from Chapter 8 of<a name="line.188"></a>
-<FONT color="green">189</FONT>         * Bevington's textbook, "Data reduction and analysis for the physical sciences").<a name="line.189"></a>
-<FONT color="green">190</FONT>         * XXX The expected ("reference") values may not be accurate and the tolerance too<a name="line.190"></a>
-<FONT color="green">191</FONT>         * relaxed for this test to be currently really useful (the issue is under<a name="line.191"></a>
-<FONT color="green">192</FONT>         * investigation).<a name="line.192"></a>
-<FONT color="green">193</FONT>         */<a name="line.193"></a>
-<FONT color="green">194</FONT>        @Test<a name="line.194"></a>
-<FONT color="green">195</FONT>        public void testBevington() {<a name="line.195"></a>
-<FONT color="green">196</FONT>            final double[][] dataPoints = {<a name="line.196"></a>
-<FONT color="green">197</FONT>                // column 1 = times<a name="line.197"></a>
-<FONT color="green">198</FONT>                { 15, 30, 45, 60, 75, 90, 105, 120, 135, 150,<a name="line.198"></a>
-<FONT color="green">199</FONT>                  165, 180, 195, 210, 225, 240, 255, 270, 285, 300,<a name="line.199"></a>
-<FONT color="green">200</FONT>                  315, 330, 345, 360, 375, 390, 405, 420, 435, 450,<a name="line.200"></a>
-<FONT color="green">201</FONT>                  465, 480, 495, 510, 525, 540, 555, 570, 585, 600,<a name="line.201"></a>
-<FONT color="green">202</FONT>                  615, 630, 645, 660, 675, 690, 705, 720, 735, 750,<a name="line.202"></a>
-<FONT color="green">203</FONT>                  765, 780, 795, 810, 825, 840, 855, 870, 885, },<a name="line.203"></a>
-<FONT color="green">204</FONT>                // column 2 = measured counts<a name="line.204"></a>
-<FONT color="green">205</FONT>                { 775, 479, 380, 302, 185, 157, 137, 119, 110, 89,<a name="line.205"></a>
-<FONT color="green">206</FONT>                  74, 61, 66, 68, 48, 54, 51, 46, 55, 29,<a name="line.206"></a>
-<FONT color="green">207</FONT>                  28, 37, 49, 26, 35, 29, 31, 24, 25, 35,<a name="line.207"></a>
-<FONT color="green">208</FONT>                  24, 30, 26, 28, 21, 18, 20, 27, 17, 17,<a name="line.208"></a>
-<FONT color="green">209</FONT>                  14, 17, 24, 11, 22, 17, 12, 10, 13, 16,<a name="line.209"></a>
-<FONT color="green">210</FONT>                  9, 9, 14, 21, 17, 13, 12, 18, 10, },<a name="line.210"></a>
-<FONT color="green">211</FONT>            };<a name="line.211"></a>
-<FONT color="green">212</FONT>    <a name="line.212"></a>
-<FONT color="green">213</FONT>            final BevingtonProblem problem = new BevingtonProblem();<a name="line.213"></a>
-<FONT color="green">214</FONT>    <a name="line.214"></a>
-<FONT color="green">215</FONT>            final int len = dataPoints[0].length;<a name="line.215"></a>
-<FONT color="green">216</FONT>            final double[] weights = new double[len];<a name="line.216"></a>
-<FONT color="green">217</FONT>            for (int i = 0; i &lt; len; i++) {<a name="line.217"></a>
-<FONT color="green">218</FONT>                problem.addPoint(dataPoints[0][i],<a name="line.218"></a>
-<FONT color="green">219</FONT>                                 dataPoints[1][i]);<a name="line.219"></a>
-<FONT color="green">220</FONT>    <a name="line.220"></a>
-<FONT color="green">221</FONT>                weights[i] = 1 / dataPoints[1][i];<a name="line.221"></a>
-<FONT color="green">222</FONT>            }<a name="line.222"></a>
-<FONT color="green">223</FONT>    <a name="line.223"></a>
-<FONT color="green">224</FONT>            final LevenbergMarquardtOptimizer optimizer<a name="line.224"></a>
-<FONT color="green">225</FONT>                = new LevenbergMarquardtOptimizer();<a name="line.225"></a>
+<FONT color="green">026</FONT>    import org.apache.commons.math3.optim.SimpleBounds;<a name="line.26"></a>
+<FONT color="green">027</FONT>    import org.apache.commons.math3.optim.nonlinear.vector.Target;<a name="line.27"></a>
+<FONT color="green">028</FONT>    import org.apache.commons.math3.optim.nonlinear.vector.Weight;<a name="line.28"></a>
+<FONT color="green">029</FONT>    import org.apache.commons.math3.optim.nonlinear.vector.ModelFunction;<a name="line.29"></a>
+<FONT color="green">030</FONT>    import org.apache.commons.math3.optim.nonlinear.vector.ModelFunctionJacobian;<a name="line.30"></a>
+<FONT color="green">031</FONT>    import org.apache.commons.math3.analysis.MultivariateVectorFunction;<a name="line.31"></a>
+<FONT color="green">032</FONT>    import org.apache.commons.math3.analysis.MultivariateMatrixFunction;<a name="line.32"></a>
+<FONT color="green">033</FONT>    import org.apache.commons.math3.exception.ConvergenceException;<a name="line.33"></a>
+<FONT color="green">034</FONT>    import org.apache.commons.math3.exception.DimensionMismatchException;<a name="line.34"></a>
+<FONT color="green">035</FONT>    import org.apache.commons.math3.exception.TooManyEvaluationsException;<a name="line.35"></a>
+<FONT color="green">036</FONT>    import org.apache.commons.math3.exception.MathUnsupportedOperationException;<a name="line.36"></a>
+<FONT color="green">037</FONT>    import org.apache.commons.math3.geometry.euclidean.twod.Vector2D;<a name="line.37"></a>
+<FONT color="green">038</FONT>    import org.apache.commons.math3.linear.SingularMatrixException;<a name="line.38"></a>
+<FONT color="green">039</FONT>    import org.apache.commons.math3.util.FastMath;<a name="line.39"></a>
+<FONT color="green">040</FONT>    import org.apache.commons.math3.util.Precision;<a name="line.40"></a>
+<FONT color="green">041</FONT>    import org.junit.Assert;<a name="line.41"></a>
+<FONT color="green">042</FONT>    import org.junit.Test;<a name="line.42"></a>
+<FONT color="green">043</FONT>    import org.junit.Ignore;<a name="line.43"></a>
+<FONT color="green">044</FONT>    <a name="line.44"></a>
+<FONT color="green">045</FONT>    /**<a name="line.45"></a>
+<FONT color="green">046</FONT>     * &lt;p&gt;Some of the unit tests are re-implementations of the MINPACK &lt;a<a name="line.46"></a>
+<FONT color="green">047</FONT>     * href="http://www.netlib.org/minpack/ex/file17"&gt;file17&lt;/a&gt; and &lt;a<a name="line.47"></a>
+<FONT color="green">048</FONT>     * href="http://www.netlib.org/minpack/ex/file22"&gt;file22&lt;/a&gt; test files.<a name="line.48"></a>
+<FONT color="green">049</FONT>     * The redistribution policy for MINPACK is available &lt;a<a name="line.49"></a>
+<FONT color="green">050</FONT>     * href="http://www.netlib.org/minpack/disclaimer"&gt;here&lt;/a&gt;, for<a name="line.50"></a>
+<FONT color="green">051</FONT>     * convenience, it is reproduced below.&lt;/p&gt;<a name="line.51"></a>
+<FONT color="green">052</FONT>    <a name="line.52"></a>
+<FONT color="green">053</FONT>     * &lt;table border="0" width="80%" cellpadding="10" align="center" bgcolor="#E0E0E0"&gt;<a name="line.53"></a>
+<FONT color="green">054</FONT>     * &lt;tr&gt;&lt;td&gt;<a name="line.54"></a>
+<FONT color="green">055</FONT>     *    Minpack Copyright Notice (1999) University of Chicago.<a name="line.55"></a>
+<FONT color="green">056</FONT>     *    All rights reserved<a name="line.56"></a>
+<FONT color="green">057</FONT>     * &lt;/td&gt;&lt;/tr&gt;<a name="line.57"></a>
+<FONT color="green">058</FONT>     * &lt;tr&gt;&lt;td&gt;<a name="line.58"></a>
+<FONT color="green">059</FONT>     * Redistribution and use in source and binary forms, with or without<a name="line.59"></a>
+<FONT color="green">060</FONT>     * modification, are permitted provided that the following conditions<a name="line.60"></a>
+<FONT color="green">061</FONT>     * are met:<a name="line.61"></a>
+<FONT color="green">062</FONT>     * &lt;ol&gt;<a name="line.62"></a>
+<FONT color="green">063</FONT>     *  &lt;li&gt;Redistributions of source code must retain the above copyright<a name="line.63"></a>
+<FONT color="green">064</FONT>     *      notice, this list of conditions and the following disclaimer.&lt;/li&gt;<a name="line.64"></a>
+<FONT color="green">065</FONT>     * &lt;li&gt;Redistributions in binary form must reproduce the above<a name="line.65"></a>
+<FONT color="green">066</FONT>     *     copyright notice, this list of conditions and the following<a name="line.66"></a>
+<FONT color="green">067</FONT>     *     disclaimer in the documentation and/or other materials provided<a name="line.67"></a>
+<FONT color="green">068</FONT>     *     with the distribution.&lt;/li&gt;<a name="line.68"></a>
+<FONT color="green">069</FONT>     * &lt;li&gt;The end-user documentation included with the redistribution, if any,<a name="line.69"></a>
+<FONT color="green">070</FONT>     *     must include the following acknowledgment:<a name="line.70"></a>
+<FONT color="green">071</FONT>     *     &lt;code&gt;This product includes software developed by the University of<a name="line.71"></a>
+<FONT color="green">072</FONT>     *           Chicago, as Operator of Argonne National Laboratory.&lt;/code&gt;<a name="line.72"></a>
+<FONT color="green">073</FONT>     *     Alternately, this acknowledgment may appear in the software itself,<a name="line.73"></a>
+<FONT color="green">074</FONT>     *     if and wherever such third-party acknowledgments normally appear.&lt;/li&gt;<a name="line.74"></a>
+<FONT color="green">075</FONT>     * &lt;li&gt;&lt;strong&gt;WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS"<a name="line.75"></a>
+<FONT color="green">076</FONT>     *     WITHOUT WARRANTY OF ANY KIND. THE COPYRIGHT HOLDER, THE<a name="line.76"></a>
+<FONT color="green">077</FONT>     *     UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND<a name="line.77"></a>
+<FONT color="green">078</FONT>     *     THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES, EXPRESS OR<a name="line.78"></a>
+<FONT color="green">079</FONT>     *     IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES<a name="line.79"></a>
+<FONT color="green">080</FONT>     *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE<a name="line.80"></a>
+<FONT color="green">081</FONT>     *     OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY<a name="line.81"></a>
+<FONT color="green">082</FONT>     *     OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR<a name="line.82"></a>
+<FONT color="green">083</FONT>     *     USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE OF<a name="line.83"></a>
+<FONT color="green">084</FONT>     *     THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4)<a name="line.84"></a>
+<FONT color="green">085</FONT>     *     DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION<a name="line.85"></a>
+<FONT color="green">086</FONT>     *     UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL<a name="line.86"></a>
+<FONT color="green">087</FONT>     *     BE CORRECTED.&lt;/strong&gt;&lt;/li&gt;<a name="line.87"></a>
+<FONT color="green">088</FONT>     * &lt;li&gt;&lt;strong&gt;LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT<a name="line.88"></a>
+<FONT color="green">089</FONT>     *     HOLDER, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF<a name="line.89"></a>
+<FONT color="green">090</FONT>     *     ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT,<a name="line.90"></a>
+<FONT color="green">091</FONT>     *     INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF<a name="line.91"></a>
+<FONT color="green">092</FONT>     *     ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF<a name="line.92"></a>
+<FONT color="green">093</FONT>     *     PROFITS OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER<a name="line.93"></a>
+<FONT color="green">094</FONT>     *     SUCH LIABILITY IS ASSERTED ON THE BASIS OF CONTRACT, TORT<a name="line.94"></a>
+<FONT color="green">095</FONT>     *     (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE,<a name="line.95"></a>
+<FONT color="green">096</FONT>     *     EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE<a name="line.96"></a>
+<FONT color="green">097</FONT>     *     POSSIBILITY OF SUCH LOSS OR DAMAGES.&lt;/strong&gt;&lt;/li&gt;<a name="line.97"></a>
+<FONT color="green">098</FONT>     * &lt;ol&gt;&lt;/td&gt;&lt;/tr&gt;<a name="line.98"></a>
+<FONT color="green">099</FONT>     * &lt;/table&gt;<a name="line.99"></a>
+<FONT color="green">100</FONT>    <a name="line.100"></a>
+<FONT color="green">101</FONT>     * @author Argonne National Laboratory. MINPACK project. March 1980 (original fortran minpack tests)<a name="line.101"></a>
+<FONT color="green">102</FONT>     * @author Burton S. Garbow (original fortran minpack tests)<a name="line.102"></a>
+<FONT color="green">103</FONT>     * @author Kenneth E. Hillstrom (original fortran minpack tests)<a name="line.103"></a>
+<FONT color="green">104</FONT>     * @author Jorge J. More (original fortran minpack tests)<a name="line.104"></a>
+<FONT color="green">105</FONT>     * @author Luc Maisonobe (non-minpack tests and minpack tests Java translation)<a name="line.105"></a>
+<FONT color="green">106</FONT>     */<a name="line.106"></a>
+<FONT color="green">107</FONT>    public class LevenbergMarquardtOptimizerTest<a name="line.107"></a>
+<FONT color="green">108</FONT>        extends AbstractLeastSquaresOptimizerAbstractTest {<a name="line.108"></a>
+<FONT color="green">109</FONT>        @Override<a name="line.109"></a>
+<FONT color="green">110</FONT>        public AbstractLeastSquaresOptimizer createOptimizer() {<a name="line.110"></a>
+<FONT color="green">111</FONT>            return new LevenbergMarquardtOptimizer();<a name="line.111"></a>
+<FONT color="green">112</FONT>        }<a name="line.112"></a>
+<FONT color="green">113</FONT>    <a name="line.113"></a>
+<FONT color="green">114</FONT>        @Test(expected=MathUnsupportedOperationException.class)<a name="line.114"></a>
+<FONT color="green">115</FONT>        public void testConstraintsUnsupported() {<a name="line.115"></a>
+<FONT color="green">116</FONT>            createOptimizer().optimize(new MaxEval(100),<a name="line.116"></a>
+<FONT color="green">117</FONT>                                       new Target(new double[] { 2 }),<a name="line.117"></a>
+<FONT color="green">118</FONT>                                       new Weight(new double[] { 1 }),<a name="line.118"></a>
+<FONT color="green">119</FONT>                                       new InitialGuess(new double[] { 1, 2 }),<a name="line.119"></a>
+<FONT color="green">120</FONT>                                       new SimpleBounds(new double[] { -10, 0 },<a name="line.120"></a>
+<FONT color="green">121</FONT>                                                        new double[] { 20, 30 }));<a name="line.121"></a>
+<FONT color="green">122</FONT>        }<a name="line.122"></a>
+<FONT color="green">123</FONT>    <a name="line.123"></a>
+<FONT color="green">124</FONT>        @Override<a name="line.124"></a>
+<FONT color="green">125</FONT>        @Test(expected=SingularMatrixException.class)<a name="line.125"></a>
+<FONT color="green">126</FONT>        public void testNonInvertible() {<a name="line.126"></a>
+<FONT color="green">127</FONT>            /*<a name="line.127"></a>
+<FONT color="green">128</FONT>             * Overrides the method from parent class, since the default singularity<a name="line.128"></a>
+<FONT color="green">129</FONT>             * threshold (1e-14) does not trigger the expected exception.<a name="line.129"></a>
+<FONT color="green">130</FONT>             */<a name="line.130"></a>
+<FONT color="green">131</FONT>            LinearProblem problem = new LinearProblem(new double[][] {<a name="line.131"></a>
+<FONT color="green">132</FONT>                    {  1, 2, -3 },<a name="line.132"></a>
+<FONT color="green">133</FONT>                    {  2, 1,  3 },<a name="line.133"></a>
+<FONT color="green">134</FONT>                    { -3, 0, -9 }<a name="line.134"></a>
+<FONT color="green">135</FONT>            }, new double[] { 1, 1, 1 });<a name="line.135"></a>
+<FONT color="green">136</FONT>    <a name="line.136"></a>
+<FONT color="green">137</FONT>            AbstractLeastSquaresOptimizer optimizer = createOptimizer();<a name="line.137"></a>
+<FONT color="green">138</FONT>            PointVectorValuePair optimum<a name="line.138"></a>
+<FONT color="green">139</FONT>                = optimizer.optimize(new MaxEval(100),<a name="line.139"></a>
+<FONT color="green">140</FONT>                                     problem.getModelFunction(),<a name="line.140"></a>
+<FONT color="green">141</FONT>                                     problem.getModelFunctionJacobian(),<a name="line.141"></a>
+<FONT color="green">142</FONT>                                     problem.getTarget(),<a name="line.142"></a>
+<FONT color="green">143</FONT>                                     new Weight(new double[] { 1, 1, 1 }),<a name="line.143"></a>
+<FONT color="green">144</FONT>                                     new InitialGuess(new double[] { 0, 0, 0 }));<a name="line.144"></a>
+<FONT color="green">145</FONT>            Assert.assertTrue(FastMath.sqrt(optimizer.getTargetSize()) * optimizer.getRMS() &gt; 0.6);<a name="line.145"></a>
+<FONT color="green">146</FONT>    <a name="line.146"></a>
+<FONT color="green">147</FONT>            optimizer.computeCovariances(optimum.getPoint(), 1.5e-14);<a name="line.147"></a>
+<FONT color="green">148</FONT>        }<a name="line.148"></a>
+<FONT color="green">149</FONT>    <a name="line.149"></a>
+<FONT color="green">150</FONT>        @Test<a name="line.150"></a>
+<FONT color="green">151</FONT>        public void testControlParameters() {<a name="line.151"></a>
+<FONT color="green">152</FONT>            CircleVectorial circle = new CircleVectorial();<a name="line.152"></a>
+<FONT color="green">153</FONT>            circle.addPoint( 30.0,  68.0);<a name="line.153"></a>
+<FONT color="green">154</FONT>            circle.addPoint( 50.0,  -6.0);<a name="line.154"></a>
+<FONT color="green">155</FONT>            circle.addPoint(110.0, -20.0);<a name="line.155"></a>
+<FONT color="green">156</FONT>            circle.addPoint( 35.0,  15.0);<a name="line.156"></a>
+<FONT color="green">157</FONT>            circle.addPoint( 45.0,  97.0);<a name="line.157"></a>
+<FONT color="green">158</FONT>            checkEstimate(circle.getModelFunction(),<a name="line.158"></a>
+<FONT color="green">159</FONT>                          circle.getModelFunctionJacobian(),<a name="line.159"></a>
+<FONT color="green">160</FONT>                          0.1, 10, 1.0e-14, 1.0e-16, 1.0e-10, false);<a name="line.160"></a>
+<FONT color="green">161</FONT>            checkEstimate(circle.getModelFunction(),<a name="line.161"></a>
+<FONT color="green">162</FONT>                          circle.getModelFunctionJacobian(),<a name="line.162"></a>
+<FONT color="green">163</FONT>                          0.1, 10, 1.0e-15, 1.0e-17, 1.0e-10, true);<a name="line.163"></a>
+<FONT color="green">164</FONT>            checkEstimate(circle.getModelFunction(),<a name="line.164"></a>
+<FONT color="green">165</FONT>                          circle.getModelFunctionJacobian(),<a name="line.165"></a>
+<FONT color="green">166</FONT>                          0.1,  5, 1.0e-15, 1.0e-16, 1.0e-10, true);<a name="line.166"></a>
+<FONT color="green">167</FONT>            circle.addPoint(300, -300);<a name="line.167"></a>
+<FONT color="green">168</FONT>            checkEstimate(circle.getModelFunction(),<a name="line.168"></a>
+<FONT color="green">169</FONT>                          circle.getModelFunctionJacobian(),<a name="line.169"></a>
+<FONT color="green">170</FONT>                          0.1, 20, 1.0e-18, 1.0e-16, 1.0e-10, true);<a name="line.170"></a>
+<FONT color="green">171</FONT>        }<a name="line.171"></a>
+<FONT color="green">172</FONT>    <a name="line.172"></a>
+<FONT color="green">173</FONT>        private void checkEstimate(ModelFunction problem,<a name="line.173"></a>
+<FONT color="green">174</FONT>                                   ModelFunctionJacobian problemJacobian,<a name="line.174"></a>
+<FONT color="green">175</FONT>                                   double initialStepBoundFactor, int maxCostEval,<a name="line.175"></a>
+<FONT color="green">176</FONT>                                   double costRelativeTolerance, double parRelativeTolerance,<a name="line.176"></a>
+<FONT color="green">177</FONT>                                   double orthoTolerance, boolean shouldFail) {<a name="line.177"></a>
+<FONT color="green">178</FONT>            try {<a name="line.178"></a>
+<FONT color="green">179</FONT>                LevenbergMarquardtOptimizer optimizer<a name="line.179"></a>
+<FONT color="green">180</FONT>                    = new LevenbergMarquardtOptimizer(initialStepBoundFactor,<a name="line.180"></a>
+<FONT color="green">181</FONT>                                                      costRelativeTolerance,<a name="line.181"></a>
+<FONT color="green">182</FONT>                                                      parRelativeTolerance,<a name="line.182"></a>
+<FONT color="green">183</FONT>                                                      orthoTolerance,<a name="line.183"></a>
+<FONT color="green">184</FONT>                                                      Precision.SAFE_MIN);<a name="line.184"></a>
+<FONT color="green">185</FONT>                optimizer.optimize(new MaxEval(maxCostEval),<a name="line.185"></a>
+<FONT color="green">186</FONT>                                   problem,<a name="line.186"></a>
+<FONT color="green">187</FONT>                                   problemJacobian,<a name="line.187"></a>
+<FONT color="green">188</FONT>                                   new Target(new double[] { 0, 0, 0, 0, 0 }),<a name="line.188"></a>
+<FONT color="green">189</FONT>                                   new Weight(new double[] { 1, 1, 1, 1, 1 }),<a name="line.189"></a>
+<FONT color="green">190</FONT>                                   new InitialGuess(new double[] { 98.680, 47.345 }));<a name="line.190"></a>
+<FONT color="green">191</FONT>                Assert.assertTrue(!shouldFail);<a name="line.191"></a>
+<FONT color="green">192</FONT>            } catch (DimensionMismatchException ee) {<a name="line.192"></a>
+<FONT color="green">193</FONT>                Assert.assertTrue(shouldFail);<a name="line.193"></a>
+<FONT color="green">194</FONT>            } catch (TooManyEvaluationsException ee) {<a name="line.194"></a>
+<FONT color="green">195</FONT>                Assert.assertTrue(shouldFail);<a name="line.195"></a>
+<FONT color="green">196</FONT>            }<a name="line.196"></a>
+<FONT color="green">197</FONT>        }<a name="line.197"></a>
+<FONT color="green">198</FONT>    <a name="line.198"></a>
+<FONT color="green">199</FONT>        /**<a name="line.199"></a>
+<FONT color="green">200</FONT>         * Non-linear test case: fitting of decay curve (from Chapter 8 of<a name="line.200"></a>
+<FONT color="green">201</FONT>         * Bevington's textbook, "Data reduction and analysis for the physical sciences").<a name="line.201"></a>
+<FONT color="green">202</FONT>         * XXX The expected ("reference") values may not be accurate and the tolerance too<a name="line.202"></a>
+<FONT color="green">203</FONT>         * relaxed for this test to be currently really useful (the issue is under<a name="line.203"></a>
+<FONT color="green">204</FONT>         * investigation).<a name="line.204"></a>
+<FONT color="green">205</FONT>         */<a name="line.205"></a>
+<FONT color="green">206</FONT>        @Test<a name="line.206"></a>
+<FONT color="green">207</FONT>        public void testBevington() {<a name="line.207"></a>
+<FONT color="green">208</FONT>            final double[][] dataPoints = {<a name="line.208"></a>
+<FONT color="green">209</FONT>                // column 1 = times<a name="line.209"></a>
+<FONT color="green">210</FONT>                { 15, 30, 45, 60, 75, 90, 105, 120, 135, 150,<a name="line.210"></a>
+<FONT color="green">211</FONT>                  165, 180, 195, 210, 225, 240, 255, 270, 285, 300,<a name="line.211"></a>
+<FONT color="green">212</FONT>                  315, 330, 345, 360, 375, 390, 405, 420, 435, 450,<a name="line.212"></a>
+<FONT color="green">213</FONT>                  465, 480, 495, 510, 525, 540, 555, 570, 585, 600,<a name="line.213"></a>
+<FONT color="green">214</FONT>                  615, 630, 645, 660, 675, 690, 705, 720, 735, 750,<a name="line.214"></a>
+<FONT color="green">215</FONT>                  765, 780, 795, 810, 825, 840, 855, 870, 885, },<a name="line.215"></a>
+<FONT color="green">216</FONT>                // column 2 = measured counts<a name="line.216"></a>
+<FONT color="green">217</FONT>                { 775, 479, 380, 302, 185, 157, 137, 119, 110, 89,<a name="line.217"></a>
+<FONT color="green">218</FONT>                  74, 61, 66, 68, 48, 54, 51, 46, 55, 29,<a name="line.218"></a>
+<FONT color="green">219</FONT>                  28, 37, 49, 26, 35, 29, 31, 24, 25, 35,<a name="line.219"></a>
+<FONT color="green">220</FONT>                  24, 30, 26, 28, 21, 18, 20, 27, 17, 17,<a name="line.220"></a>
+<FONT color="green">221</FONT>                  14, 17, 24, 11, 22, 17, 12, 10, 13, 16,<a name="line.221"></a>
+<FONT color="green">222</FONT>                  9, 9, 14, 21, 17, 13, 12, 18, 10, },<a name="line.222"></a>
+<FONT color="green">223</FONT>            };<a name="line.223"></a>
+<FONT color="green">224</FONT>    <a name="line.224"></a>
+<FONT color="green">225</FONT>            final BevingtonProblem problem = new BevingtonProblem();<a name="line.225"></a>
 <FONT color="green">226</FONT>    <a name="line.226"></a>
-<FONT color="green">227</FONT>            final PointVectorValuePair optimum<a name="line.227"></a>
-<FONT color="green">228</FONT>                = optimizer.optimize(new MaxEval(100),<a name="line.228"></a>
-<FONT color="green">229</FONT>                                     problem.getModelFunction(),<a name="line.229"></a>
-<FONT color="green">230</FONT>                                     problem.getModelFunctionJacobian(),<a name="line.230"></a>
-<FONT color="green">231</FONT>                                     new Target(dataPoints[1]),<a name="line.231"></a>
-<FONT color="green">232</FONT>                                     new Weight(weights),<a name="line.232"></a>
-<FONT color="green">233</FONT>                                     new InitialGuess(new double[] { 10, 900, 80, 27, 225 }));<a name="line.233"></a>
-<FONT color="green">234</FONT>    <a name="line.234"></a>
-<FONT color="green">235</FONT>            final double[] solution = optimum.getPoint();<a name="line.235"></a>
-<FONT color="green">236</FONT>            final double[] expectedSolution = { 10.4, 958.3, 131.4, 33.9, 205.0 };<a name="line.236"></a>
-<FONT color="green">237</FONT>    <a name="line.237"></a>
-<FONT color="green">238</FONT>            final double[][] covarMatrix = optimizer.computeCovariances(solution, 1e-14);<a name="line.238"></a>
-<FONT color="green">239</FONT>            final double[][] expectedCovarMatrix = {<a name="line.239"></a>
-<FONT color="green">240</FONT>                { 3.38, -3.69, 27.98, -2.34, -49.24 },<a name="line.240"></a>
-<FONT color="green">241</FONT>                { -3.69, 2492.26, 81.89, -69.21, -8.9 },<a name="line.241"></a>
-<FONT color="green">242</FONT>                { 27.98, 81.89, 468.99, -44.22, -615.44 },<a name="line.242"></a>
-<FONT color="green">243</FONT>                { -2.34, -69.21, -44.22, 6.39, 53.80 },<a name="line.243"></a>
-<FONT color="green">244</FONT>                { -49.24, -8.9, -615.44, 53.8, 929.45 }<a name="line.244"></a>
-<FONT color="green">245</FONT>            };<a name="line.245"></a>
+<FONT color="green">227</FONT>            final int len = dataPoints[0].length;<a name="line.227"></a>
+<FONT color="green">228</FONT>            final double[] weights = new double[len];<a name="line.228"></a>
+<FONT color="green">229</FONT>            for (int i = 0; i &lt; len; i++) {<a name="line.229"></a>
+<FONT color="green">230</FONT>                problem.addPoint(dataPoints[0][i],<a name="line.230"></a>
+<FONT color="green">231</FONT>                                 dataPoints[1][i]);<a name="line.231"></a>
+<FONT color="green">232</FONT>    <a name="line.232"></a>
+<FONT color="green">233</FONT>                weights[i] = 1 / dataPoints[1][i];<a name="line.233"></a>
+<FONT color="green">234</FONT>            }<a name="line.234"></a>
+<FONT color="green">235</FONT>    <a name="line.235"></a>
+<FONT color="green">236</FONT>            final LevenbergMarquardtOptimizer optimizer<a name="line.236"></a>
+<FONT color="green">237</FONT>                = new LevenbergMarquardtOptimizer();<a name="line.237"></a>
+<FONT color="green">238</FONT>    <a name="line.238"></a>
+<FONT color="green">239</FONT>            final PointVectorValuePair optimum<a name="line.239"></a>
+<FONT color="green">240</FONT>                = optimizer.optimize(new MaxEval(100),<a name="line.240"></a>
+<FONT color="green">241</FONT>                                     problem.getModelFunction(),<a name="line.241"></a>
+<FONT color="green">242</FONT>                                     problem.getModelFunctionJacobian(),<a name="line.242"></a>
+<FONT color="green">243</FONT>                                     new Target(dataPoints[1]),<a name="line.243"></a>
+<FONT color="green">244</FONT>                                     new Weight(weights),<a name="line.244"></a>
+<FONT color="green">245</FONT>                                     new InitialGuess(new double[] { 10, 900, 80, 27, 225 }));<a name="line.245"></a>
 <FONT color="green">246</FONT>    <a name="line.246"></a>
-<FONT color="green">247</FONT>            final int numParams = expectedSolution.length;<a name="line.247"></a>
-<FONT color="green">248</FONT>    <a name="line.248"></a>
-<FONT color="green">249</FONT>            // Check that the computed solution is within the reference error range.<a name="line.249"></a>
-<FONT color="green">250</FONT>            for (int i = 0; i &lt; numParams; i++) {<a name="line.250"></a>
-<FONT color="green">251</FONT>                final double error = FastMath.sqrt(expectedCovarMatrix[i][i]);<a name="line.251"></a>
-<FONT color="green">252</FONT>                Assert.assertEquals("Parameter " + i, expectedSolution[i], solution[i], error);<a name="line.252"></a>
-<FONT color="green">253</FONT>            }<a name="line.253"></a>
-<FONT color="green">254</FONT>    <a name="line.254"></a>
-<FONT color="green">255</FONT>            // Check that each entry of the computed covariance matrix is within 10%<a name="line.255"></a>
-<FONT color="green">256</FONT>            // of the reference matrix entry.<a name="line.256"></a>
-<FONT color="green">257</FONT>            for (int i = 0; i &lt; numParams; i++) {<a name="line.257"></a>
-<FONT color="green">258</FONT>                for (int j = 0; j &lt; numParams; j++) {<a name="line.258"></a>
-<FONT color="green">259</FONT>                    Assert.assertEquals("Covariance matrix [" + i + "][" + j + "]",<a name="line.259"></a>
-<FONT color="green">260</FONT>                                        expectedCovarMatrix[i][j],<a name="line.260"></a>
-<FONT color="green">261</FONT>                                        covarMatrix[i][j],<a name="line.261"></a>
-<FONT color="green">262</FONT>                                        FastMath.abs(0.1 * expectedCovarMatrix[i][j]));<a name="line.262"></a>
-<FONT color="green">263</FONT>                }<a name="line.263"></a>
-<FONT color="green">264</FONT>            }<a name="line.264"></a>
-<FONT color="green">265</FONT>        }<a name="line.265"></a>
+<FONT color="green">247</FONT>            final double[] solution = optimum.getPoint();<a name="line.247"></a>
+<FONT color="green">248</FONT>            final double[] expectedSolution = { 10.4, 958.3, 131.4, 33.9, 205.0 };<a name="line.248"></a>
+<FONT color="green">249</FONT>    <a name="line.249"></a>
+<FONT color="green">250</FONT>            final double[][] covarMatrix = optimizer.computeCovariances(solution, 1e-14);<a name="line.250"></a>
+<FONT color="green">251</FONT>            final double[][] expectedCovarMatrix = {<a name="line.251"></a>
+<FONT color="green">252</FONT>                { 3.38, -3.69, 27.98, -2.34, -49.24 },<a name="line.252"></a>
+<FONT color="green">253</FONT>                { -3.69, 2492.26, 81.89, -69.21, -8.9 },<a name="line.253"></a>
+<FONT color="green">254</FONT>                { 27.98, 81.89, 468.99, -44.22, -615.44 },<a name="line.254"></a>
+<FONT color="green">255</FONT>                { -2.34, -69.21, -44.22, 6.39, 53.80 },<a name="line.255"></a>
+<FONT color="green">256</FONT>                { -49.24, -8.9, -615.44, 53.8, 929.45 }<a name="line.256"></a>
+<FONT color="green">257</FONT>            };<a name="line.257"></a>
+<FONT color="green">258</FONT>    <a name="line.258"></a>
+<FONT color="green">259</FONT>            final int numParams = expectedSolution.length;<a name="line.259"></a>
+<FONT color="green">260</FONT>    <a name="line.260"></a>
+<FONT color="green">261</FONT>            // Check that the computed solution is within the reference error range.<a name="line.261"></a>
+<FONT color="green">262</FONT>            for (int i = 0; i &lt; numParams; i++) {<a name="line.262"></a>
+<FONT color="green">263</FONT>                final double error = FastMath.sqrt(expectedCovarMatrix[i][i]);<a name="line.263"></a>
+<FONT color="green">264</FONT>                Assert.assertEquals("Parameter " + i, expectedSolution[i], solution[i], error);<a name="line.264"></a>
+<FONT color="green">265</FONT>            }<a name="line.265"></a>
 <FONT color="green">266</FONT>    <a name="line.266"></a>
-<FONT color="green">267</FONT>        @Test<a name="line.267"></a>
-<FONT color="green">268</FONT>        public void testCircleFitting2() {<a name="line.268"></a>
-<FONT color="green">269</FONT>            final double xCenter = 123.456;<a name="line.269"></a>
-<FONT color="green">270</FONT>            final double yCenter = 654.321;<a name="line.270"></a>
-<FONT color="green">271</FONT>            final double xSigma = 10;<a name="line.271"></a>
-<FONT color="green">272</FONT>            final double ySigma = 15;<a name="line.272"></a>
-<FONT color="green">273</FONT>            final double radius = 111.111;<a name="line.273"></a>
-<FONT color="green">274</FONT>            // The test is extremely sensitive to the seed.<a name="line.274"></a>
-<FONT color="green">275</FONT>            final long seed = 59421061L;<a name="line.275"></a>
-<FONT color="green">276</FONT>            final RandomCirclePointGenerator factory<a name="line.276"></a>
-<FONT color="green">277</FONT>                = new RandomCirclePointGenerator(xCenter, yCenter, radius,<a name="line.277"></a>
-<FONT color="green">278</FONT>                                                 xSigma, ySigma,<a name="line.278"></a>
-<FONT color="green">279</FONT>                                                 seed);<a name="line.279"></a>
-<FONT color="green">280</FONT>            final CircleProblem circle = new CircleProblem(xSigma, ySigma);<a name="line.280"></a>
-<FONT color="green">281</FONT>    <a name="line.281"></a>
-<FONT color="green">282</FONT>            final int numPoints = 10;<a name="line.282"></a>
-<FONT color="green">283</FONT>            for (Vector2D p : factory.generate(numPoints)) {<a name="line.283"></a>
-<FONT color="green">284</FONT>                circle.addPoint(p.getX(), p.getY());<a name="line.284"></a>
-<FONT color="green">285</FONT>            }<a name="line.285"></a>
-<FONT color="green">286</FONT>    <a name="line.286"></a>
-<FONT color="green">287</FONT>            // First guess for the center's coordinates and radius.<a name="line.287"></a>
-<FONT color="green">288</FONT>            final double[] init = { 90, 659, 115 };<a name="line.288"></a>
-<FONT color="green">289</FONT>    <a name="line.289"></a>
-<FONT color="green">290</FONT>            final LevenbergMarquardtOptimizer optimizer<a name="line.290"></a>
-<FONT color="green">291</FONT>                = new LevenbergMarquardtOptimizer();<a name="line.291"></a>
-<FONT color="green">292</FONT>            final PointVectorValuePair optimum = optimizer.optimize(new MaxEval(100),<a name="line.292"></a>
-<FONT color="green">293</FONT>                                                                    circle.getModelFunction(),<a name="line.293"></a>
-<FONT color="green">294</FONT>                                                                    circle.getModelFunctionJacobian(),<a name="line.294"></a>
-<FONT color="green">295</FONT>                                                                    new Target(circle.target()),<a name="line.295"></a>
-<FONT color="green">296</FONT>                                                                    new Weight(circle.weight()),<a name="line.296"></a>
-<FONT color="green">297</FONT>                                                                    new InitialGuess(init));<a name="line.297"></a>
+<FONT color="green">267</FONT>            // Check that each entry of the computed covariance matrix is within 10%<a name="line.267"></a>
+<FONT color="green">268</FONT>            // of the reference matrix entry.<a name="line.268"></a>
+<FONT color="green">269</FONT>            for (int i = 0; i &lt; numParams; i++) {<a name="line.269"></a>
+<FONT color="green">270</FONT>                for (int j = 0; j &lt; numParams; j++) {<a name="line.270"></a>
+<FONT color="green">271</FONT>                    Assert.assertEquals("Covariance matrix [" + i + "][" + j + "]",<a name="line.271"></a>
+<FONT color="green">272</FONT>                                        expectedCovarMatrix[i][j],<a name="line.272"></a>
+<FONT color="green">273</FONT>                                        covarMatrix[i][j],<a name="line.273"></a>
+<FONT color="green">274</FONT>                                        FastMath.abs(0.1 * expectedCovarMatrix[i][j]));<a name="line.274"></a>
+<FONT color="green">275</FONT>                }<a name="line.275"></a>
+<FONT color="green">276</FONT>            }<a name="line.276"></a>
+<FONT color="green">277</FONT>        }<a name="line.277"></a>
+<FONT color="green">278</FONT>    <a name="line.278"></a>
+<FONT color="green">279</FONT>        @Test<a name="line.279"></a>
+<FONT color="green">280</FONT>        public void testCircleFitting2() {<a name="line.280"></a>
+<FONT color="green">281</FONT>            final double xCenter = 123.456;<a name="line.281"></a>
+<FONT color="green">282</FONT>            final double yCenter = 654.321;<a name="line.282"></a>
+<FONT color="green">283</FONT>            final double xSigma = 10;<a name="line.283"></a>
+<FONT color="green">284</FONT>            final double ySigma = 15;<a name="line.284"></a>
+<FONT color="green">285</FONT>            final double radius = 111.111;<a name="line.285"></a>
+<FONT color="green">286</FONT>            // The test is extremely sensitive to the seed.<a name="line.286"></a>
+<FONT color="green">287</FONT>            final long seed = 59421061L;<a name="line.287"></a>
+<FONT color="green">288</FONT>            final RandomCirclePointGenerator factory<a name="line.288"></a>
+<FONT color="green">289</FONT>                = new RandomCirclePointGenerator(xCenter, yCenter, radius,<a name="line.289"></a>
+<FONT color="green">290</FONT>                                                 xSigma, ySigma,<a name="line.290"></a>
+<FONT color="green">291</FONT>                                                 seed);<a name="line.291"></a>
+<FONT color="green">292</FONT>            final CircleProblem circle = new CircleProblem(xSigma, ySigma);<a name="line.292"></a>
+<FONT color="green">293</FONT>    <a name="line.293"></a>
+<FONT color="green">294</FONT>            final int numPoints = 10;<a name="line.294"></a>
+<FONT color="green">295</FONT>            for (Vector2D p : factory.generate(numPoints)) {<a name="line.295"></a>
+<FONT color="green">296</FONT>                circle.addPoint(p.getX(), p.getY());<a name="line.296"></a>
+<FONT color="green">297</FONT>            }<a name="line.297"></a>
 <FONT color="green">298</FONT>    <a name="line.298"></a>
-<FONT color="green">299</FONT>            final double[] paramFound = optimum.getPoint();<a name="line.299"></a>
-<FONT color="green">300</FONT>    <a name="line.300"></a>
-<FONT color="green">301</FONT>            // Retrieve errors estimation.<a name="line.301"></a>
-<FONT color="green">302</FONT>            final double[] asymptoticStandardErrorFound = optimizer.computeSigma(paramFound, 1e-14);<a name="line.302"></a>
-<FONT color="green">303</FONT>    <a name="line.303"></a>
-<FONT color="green">304</FONT>            // Check that the parameters are found within the assumed error bars.<a name="line.304"></a>
-<FONT color="green">305</FONT>            Assert.assertEquals(xCenter, paramFound[0], asymptoticStandardErrorFound[0]);<a name="line.305"></a>
-<FONT color="green">306</FONT>            Assert.assertEquals(yCenter, paramFound[1], asymptoticStandardErrorFound[1]);<a name="line.306"></a>
-<FONT color="green">307</FONT>            Assert.assertEquals(radius, paramFound[2], asymptoticStandardErrorFound[2]);<a name="line.307"></a>
-<FONT color="green">308</FONT>        }<a name="line.308"></a>
-<FONT color="green">309</FONT>    <a name="line.309"></a>
-<FONT color="green">310</FONT>        private static class QuadraticProblem {<a name="line.310"></a>
-<FONT color="green">311</FONT>            private List&lt;Double&gt; x;<a name="line.311"></a>
-<FONT color="green">312</FONT>            private List&lt;Double&gt; y;<a name="line.312"></a>
-<FONT color="green">313</FONT>    <a name="line.313"></a>
-<FONT color="green">314</FONT>            public QuadraticProblem() {<a name="line.314"></a>
-<FONT color="green">315</FONT>                x = new ArrayList&lt;Double&gt;();<a name="line.315"></a>
-<FONT color="green">316</FONT>                y = new ArrayList&lt;Double&gt;();<a name="line.316"></a>
-<FONT color="green">317</FONT>            }<a name="line.317"></a>
-<FONT color="green">318</FONT>    <a name="line.318"></a>
-<FONT color="green">319</FONT>            public void addPoint(double x, double y) {<a name="line.319"></a>
-<FONT color="green">320</FONT>                this.x.add(x);<a name="line.320"></a>
-<FONT color="green">321</FONT>                this.y.add(y);<a name="line.321"></a>
-<FONT color="green">322</FONT>            }<a name="line.322"></a>
-<FONT color="green">323</FONT>    <a name="line.323"></a>
-<FONT color="green">324</FONT>            public ModelFunction getModelFunction() {<a name="line.324"></a>
-<FONT color="green">325</FONT>                return new ModelFunction(new MultivariateVectorFunction() {<a name="line.325"></a>
-<FONT color="green">326</FONT>                        public double[] value(double[] variables) {<a name="line.326"></a>
-<FONT color="green">327</FONT>                            double[] values = new double[x.size()];<a name="line.327"></a>
-<FONT color="green">328</FONT>                            for (int i = 0; i &lt; values.length; ++i) {<a name="line.328"></a>
-<FONT color="green">329</FONT>                                values[i] = (variables[0] * x.get(i) + variables[1]) * x.get(i) + variables[2];<a name="line.329"></a>
-<FONT color="green">330</FONT>                            }<a name="line.330"></a>
-<FONT color="green">331</FONT>                            return values;<a name="line.331"></a>
-<FONT color="green">332</FONT>                        }<a name="line.332"></a>
-<FONT color="green">333</FONT>                    });<a name="line.333"></a>
+<FONT color="green">299</FONT>            // First guess for the center's coordinates and radius.<a name="line.299"></a>
+<FONT color="green">300</FONT>            final double[] init = { 90, 659, 115 };<a name="line.300"></a>
+<FONT color="green">301</FONT>    <a name="line.301"></a>
+<FONT color="green">302</FONT>            final LevenbergMarquardtOptimizer optimizer<a name="line.302"></a>
+<FONT color="green">303</FONT>                = new LevenbergMarquardtOptimizer();<a name="line.303"></a>
+<FONT color="green">304</FONT>            final PointVectorValuePair optimum = optimizer.optimize(new MaxEval(100),<a name="line.304"></a>
+<FONT color="green">305</FONT>                                                                    circle.getModelFunction(),<a name="line.305"></a>
+<FONT color="green">306</FONT>                                                                    circle.getModelFunctionJacobian(),<a name="line.306"></a>
+<FONT color="green">307</FONT>                                                                    new Target(circle.target()),<a name="line.307"></a>
+<FONT color="green">308</FONT>                                                                    new Weight(circle.weight()),<a name="line.308"></a>
+<FONT color="green">309</FONT>                                                                    new InitialGuess(init));<a name="line.309"></a>
+<FONT color="green">310</FONT>    <a name="line.310"></a>
+<FONT color="green">311</FONT>            final double[] paramFound = optimum.getPoint();<a name="line.311"></a>
+<FONT color="green">312</FONT>    <a name="line.312"></a>
+<FONT color="green">313</FONT>            // Retrieve errors estimation.<a name="line.313"></a>
+<FONT color="green">314</FONT>            final double[] asymptoticStandardErrorFound = optimizer.computeSigma(paramFound, 1e-14);<a name="line.314"></a>
+<FONT color="green">315</FONT>    <a name="line.315"></a>
+<FONT color="green">316</FONT>            // Check that the parameters are found within the assumed error bars.<a name="line.316"></a>
+<FONT color="green">317</FONT>            Assert.assertEquals(xCenter, paramFound[0], asymptoticStandardErrorFound[0]);<a name="line.317"></a>
+<FONT color="green">318</FONT>            Assert.assertEquals(yCenter, paramFound[1], asymptoticStandardErrorFound[1]);<a name="line.318"></a>
+<FONT color="green">319</FONT>            Assert.assertEquals(radius, paramFound[2], asymptoticStandardErrorFound[2]);<a name="line.319"></a>
+<FONT color="green">320</FONT>        }<a name="line.320"></a>
+<FONT color="green">321</FONT>    <a name="line.321"></a>
+<FONT color="green">322</FONT>        private static class QuadraticProblem {<a name="line.322"></a>
+<FONT color="green">323</FONT>            private List&lt;Double&gt; x;<a name="line.323"></a>
+<FONT color="green">324</FONT>            private List&lt;Double&gt; y;<a name="line.324"></a>
+<FONT color="green">325</FONT>    <a name="line.325"></a>
+<FONT color="green">326</FONT>            public QuadraticProblem() {<a name="line.326"></a>
+<FONT color="green">327</FONT>                x = new ArrayList&lt;Double&gt;();<a name="line.327"></a>
+<FONT color="green">328</FONT>                y = new ArrayList&lt;Double&gt;();<a name="line.328"></a>
+<FONT color="green">329</FONT>            }<a name="line.329"></a>
+<FONT color="green">330</FONT>    <a name="line.330"></a>
+<FONT color="green">331</FONT>            public void addPoint(double x, double y) {<a name="line.331"></a>
+<FONT color="green">332</FONT>                this.x.add(x);<a name="line.332"></a>
+<FONT color="green">333</FONT>                this.y.add(y);<a name="line.333"></a>
 <FONT color="green">334</FONT>            }<a name="line.334"></a>
 <FONT color="green">335</FONT>    <a name="line.335"></a>
-<FONT color="green">336</FONT>            public ModelFunctionJacobian getModelFunctionJacobian() {<a name="line.336"></a>
-<FONT color="green">337</FONT>                return new ModelFunctionJacobian(new MultivariateMatrixFunction() {<a name="line.337"></a>
-<FONT color="green">338</FONT>                        public double[][] value(double[] params) {                    <a name="line.338"></a>
-<FONT color="green">339</FONT>                            double[][] jacobian = new double[x.size()][3];<a name="line.339"></a>
-<FONT color="green">340</FONT>                            for (int i = 0; i &lt; jacobian.length; ++i) {<a name="line.340"></a>
-<FONT color="green">341</FONT>                                jacobian[i][0] = x.get(i) * x.get(i);<a name="line.341"></a>
-<FONT color="green">342</FONT>                                jacobian[i][1] = x.get(i);<a name="line.342"></a>
-<FONT color="green">343</FONT>                                jacobian[i][2] = 1.0;<a name="line.343"></a>
-<FONT color="green">344</FONT>                            }<a name="line.344"></a>
-<FONT color="green">345</FONT>                            return jacobian;<a name="line.345"></a>
-<FONT color="green">346</FONT>                        }<a name="line.346"></a>
-<FONT color="green">347</FONT>                    });<a name="line.347"></a>
-<FONT color="green">348</FONT>            }<a name="line.348"></a>
-<FONT color="green">349</FONT>        }<a name="line.349"></a>
-<FONT color="green">350</FONT>    <a name="line.350"></a>
-<FONT color="green">351</FONT>        private static class BevingtonProblem {<a name="line.351"></a>
-<FONT color="green">352</FONT>            private List&lt;Double&gt; time;<a name="line.352"></a>
-<FONT color="green">353</FONT>            private List&lt;Double&gt; count;<a name="line.353"></a>
-<FONT color="green">354</FONT>    <a name="line.354"></a>
-<FONT color="green">355</FONT>            public BevingtonProblem() {<a name="line.355"></a>
-<FONT color="green">356</FONT>                time = new ArrayList&lt;Double&gt;();<a name="line.356"></a>
-<FONT color="green">357</FONT>                count = new ArrayList&lt;Double&gt;();<a name="line.357"></a>
-<FONT color="green">358</FONT>            }<a name="line.358"></a>
-<FONT color="green">359</FONT>    <a name="line.359"></a>
-<FONT color="green">360</FONT>            public void addPoint(double t, double c) {<a name="line.360"></a>
-<FONT color="green">361</FONT>                time.add(t);<a name="line.361"></a>
-<FONT color="green">362</FONT>                count.add(c);<a name="line.362"></a>
-<FONT color="green">363</FONT>            }<a name="line.363"></a>
-<FONT color="green">364</FONT>    <a name="line.364"></a>
-<FONT color="green">365</FONT>            public ModelFunction getModelFunction() {<a name="line.365"></a>
-<FONT color="green">366</FONT>                return new ModelFunction(new MultivariateVectorFunction() {<a name="line.366"></a>
-<FONT color="green">367</FONT>                        public double[] value(double[] params) {<a name="line.367"></a>
-<FONT color="green">368</FONT>                            double[] values = new double[time.size()];<a name="line.368"></a>
-<FONT color="green">369</FONT>                            for (int i = 0; i &lt; values.length; ++i) {<a name="line.369"></a>
-<FONT color="green">370</FONT>                                final double t = time.get(i);<a name="line.370"></a>
-<FONT color="green">371</FONT>                                values[i] = params[0] +<a name="line.371"></a>
-<FONT color="green">372</FONT>                                    params[1] * Math.exp(-t / params[3]) +<a name="line.372"></a>
-<FONT color="green">373</FONT>                                    params[2] * Math.exp(-t / params[4]);<a name="line.373"></a>
-<FONT color="green">374</FONT>                            }<a name="line.374"></a>
-<FONT color="green">375</FONT>                            return values;<a name="line.375"></a>
-<FONT color="green">376</FONT>                        }<a name="line.376"></a>
-<FONT color="green">377</FONT>                    });<a name="line.377"></a>
-<FONT color="green">378</FONT>            }<a name="line.378"></a>
-<FONT color="green">379</FONT>    <a name="line.379"></a>
-<FONT color="green">380</FONT>            public ModelFunctionJacobian getModelFunctionJacobian() {<a name="line.380"></a>
-<FONT color="green">381</FONT>                return new ModelFunctionJacobian(new MultivariateMatrixFunction() {<a name="line.381"></a>
-<FONT color="green">382</FONT>                        public double[][] value(double[] params) {<a name="line.382"></a>
-<FONT color="green">383</FONT>                            double[][] jacobian = new double[time.size()][5];<a name="line.383"></a>
-<FONT color="green">384</FONT>    <a name="line.384"></a>
-<FONT color="green">385</FONT>                            for (int i = 0; i &lt; jacobian.length; ++i) {<a name="line.385"></a>
-<FONT color="green">386</FONT>                                final double t = time.get(i);<a name="line.386"></a>
-<FONT color="green">387</FONT>                                jacobian[i][0] = 1;<a name="line.387"></a>
-<FONT color="green">388</FONT>    <a name="line.388"></a>
-<FONT color="green">389</FONT>                                final double p3 =  params[3];<a name="line.389"></a>
-<FONT color="green">390</FONT>                                final double p4 =  params[4];<a name="line.390"></a>
-<FONT color="green">391</FONT>                                final double tOp3 = t / p3;<a name="line.391"></a>
-<FONT color="green">392</FONT>                                final double tOp4 = t / p4;<a name="line.392"></a>
-<FONT color="green">393</FONT>                                jacobian[i][1] = Math.exp(-tOp3);<a name="line.393"></a>
-<FONT color="green">394</FONT>                                jacobian[i][2] = Math.exp(-tOp4);<a name="line.394"></a>
-<FONT color="green">395</FONT>                                jacobian[i][3] = params[1] * Math.exp(-tOp3) * tOp3 / p3;<a name="line.395"></a>
-<FONT color="green">396</FONT>                                jacobian[i][4] = params[2] * Math.exp(-tOp4) * tOp4 / p4;<a name="line.396"></a>
-<FONT color="green">397</FONT>                            }<a name="line.397"></a>
-<FONT color="green">398</FONT>                            return jacobian;<a name="line.398"></a>
-<FONT color="green">399</FONT>                        }<a name="line.399"></a>
-<FONT color="green">400</FONT>                    });<a name="line.400"></a>
-<FONT color="green">401</FONT>            }<a name="line.401"></a>
-<FONT color="green">402</FONT>        }<a name="line.402"></a>
-<FONT color="green">403</FONT>    }<a name="line.403"></a>
+<FONT color="green">336</FONT>            public ModelFunction getModelFunction() {<a name="line.336"></a>
+<FONT color="green">337</FONT>                return new ModelFunction(new MultivariateVectorFunction() {<a name="line.337"></a>
+<FONT color="green">338</FONT>                        public double[] value(double[] variables) {<a name="line.338"></a>
+<FONT color="green">339</FONT>                            double[] values = new double[x.size()];<a name="line.339"></a>
+<FONT color="green">340</FONT>                            for (int i = 0; i &lt; values.length; ++i) {<a name="line.340"></a>
+<FONT color="green">341</FONT>                                values[i] = (variables[0] * x.get(i) + variables[1]) * x.get(i) + variables[2];<a name="line.341"></a>
+<FONT color="green">342</FONT>                            }<a name="line.342"></a>
+<FONT color="green">343</FONT>                            return values;<a name="line.343"></a>
+<FONT color="green">344</FONT>                        }<a name="line.344"></a>
+<FONT color="green">345</FONT>                    });<a name="line.345"></a>
+<FONT color="green">346</FONT>            }<a name="line.346"></a>
+<FONT color="green">347</FONT>    <a name="line.347"></a>
+<FONT color="green">348</FONT>            public ModelFunctionJacobian getModelFunctionJacobian() {<a name="line.348"></a>
+<FONT color="green">349</FONT>                return new ModelFunctionJacobian(new MultivariateMatrixFunction() {<a name="line.349"></a>
+<FONT color="green">350</FONT>                        public double[][] value(double[] params) {                    <a name="line.350"></a>
+<FONT color="green">351</FONT>                            double[][] jacobian = new double[x.size()][3];<a name="line.351"></a>
+<FONT color="green">352</FONT>                            for (int i = 0; i &lt; jacobian.length; ++i) {<a name="line.352"></a>
+<FONT color="green">353</FONT>                                jacobian[i][0] = x.get(i) * x.get(i);<a name="line.353"></a>
+<FONT color="green">354</FONT>                                jacobian[i][1] = x.get(i);<a name="line.354"></a>
+<FONT color="green">355</FONT>                                jacobian[i][2] = 1.0;<a name="line.355"></a>
+<FONT color="green">356</FONT>                            }<a name="line.356"></a>
+<FONT color="green">357</FONT>                            return jacobian;<a name="line.357"></a>
+<FONT color="green">358</FONT>                        }<a name="line.358"></a>
+<FONT color="green">359</FONT>                    });<a name="line.359"></a>
+<FONT color="green">360</FONT>            }<a name="line.360"></a>
+<FONT color="green">361</FONT>        }<a name="line.361"></a>
+<FONT color="green">362</FONT>    <a name="line.362"></a>
+<FONT color="green">363</FONT>        private static class BevingtonProblem {<a name="line.363"></a>
+<FONT color="green">364</FONT>            private List&lt;Double&gt; time;<a name="line.364"></a>
+<FONT color="green">365</FONT>            private List&lt;Double&gt; count;<a name="line.365"></a>
+<FONT color="green">366</FONT>    <a name="line.366"></a>
+<FONT color="green">367</FONT>            public BevingtonProblem() {<a name="line.367"></a>
+<FONT color="green">368</FONT>                time = new ArrayList&lt;Double&gt;();<a name="line.368"></a>
+<FONT color="green">369</FONT>                count = new ArrayList&lt;Double&gt;();<a name="line.369"></a>
+<FONT color="green">370</FONT>            }<a name="line.370"></a>
+<FONT color="green">371</FONT>    <a name="line.371"></a>
+<FONT color="green">372</FONT>            public void addPoint(double t, double c) {<a name="line.372"></a>
+<FONT color="green">373</FONT>                time.add(t);<a name="line.373"></a>
+<FONT color="green">374</FONT>                count.add(c);<a name="line.374"></a>
+<FONT color="green">375</FONT>            }<a name="line.375"></a>
+<FONT color="green">376</FONT>    <a name="line.376"></a>
+<FONT color="green">377</FONT>            public ModelFunction getModelFunction() {<a name="line.377"></a>
+<FONT color="green">378</FONT>                return new ModelFunction(new MultivariateVectorFunction() {<a name="line.378"></a>
+<FONT color="green">379</FONT>                        public double[] value(double[] params) {<a name="line.379"></a>
+<FONT color="green">380</FONT>                            double[] values = new double[time.size()];<a name="line.380"></a>
+<FONT color="green">381</FONT>                            for (int i = 0; i &lt; values.length; ++i) {<a name="line.381"></a>
+<FONT color="green">382</FONT>                                final double t = time.get(i);<a name="line.382"></a>
+<FONT color="green">383</FONT>                                values[i] = params[0] +<a name="line.383"></a>
+<FONT color="green">384</FONT>                                    params[1] * Math.exp(-t / params[3]) +<a name="line.384"></a>
+<FONT color="green">385</FONT>                                    params[2] * Math.exp(-t / params[4]);<a name="line.385"></a>
+<FONT color="green">386</FONT>                            }<a name="line.386"></a>
+<FONT color="green">387</FONT>                            return values;<a name="line.387"></a>
+<FONT color="green">388</FONT>                        }<a name="line.388"></a>
+<FONT color="green">389</FONT>                    });<a name="line.389"></a>
+<FONT color="green">390</FONT>            }<a name="line.390"></a>
+<FONT color="green">391</FONT>    <a name="line.391"></a>
+<FONT color="green">392</FONT>            public ModelFunctionJacobian getModelFunctionJacobian() {<a name="line.392"></a>
+<FONT color="green">393</FONT>                return new ModelFunctionJacobian(new MultivariateMatrixFunction() {<a name="line.393"></a>
+<FONT color="green">394</FONT>                        public double[][] value(double[] params) {<a name="line.394"></a>
+<FONT color="green">395</FONT>                            double[][] jacobian = new double[time.size()][5];<a name="line.395"></a>
+<FONT color="green">396</FONT>    <a name="line.396"></a>
+<FONT color="green">397</FONT>                            for (int i = 0; i &lt; jacobian.length; ++i) {<a name="line.397"></a>
+<FONT color="green">398</FONT>                                final double t = time.get(i);<a name="line.398"></a>
+<FONT color="green">399</FONT>                                jacobian[i][0] = 1;<a name="line.399"></a>
+<FONT color="green">400</FONT>    <a name="line.400"></a>
+<FONT color="green">401</FONT>                                final double p3 =  params[3];<a name="line.401"></a>
+<FONT color="green">402</FONT>                                final double p4 =  params[4];<a name="line.402"></a>
+<FONT color="green">403</FONT>                                final double tOp3 = t / p3;<a name="line.403"></a>
+<FONT color="green">404</FONT>                                final double tOp4 = t / p4;<a name="line.404"></a>
+<FONT color="green">405</FONT>                                jacobian[i][1] = Math.exp(-tOp3);<a name="line.405"></a>
+<FONT color="green">406</FONT>                                jacobian[i][2] = Math.exp(-tOp4);<a name="line.406"></a>
+<FONT color="green">407</FONT>                                jacobian[i][3] = params[1] * Math.exp(-tOp3) * tOp3 / p3;<a name="line.407"></a>
+<FONT color="green">408</FONT>                                jacobian[i][4] = params[2] * Math.exp(-tOp4) * tOp4 / p4;<a name="line.408"></a>
+<FONT color="green">409</FONT>                            }<a name="line.409"></a>
+<FONT color="green">410</FONT>                            return jacobian;<a name="line.410"></a>
+<FONT color="green">411</FONT>                        }<a name="line.411"></a>
+<FONT color="green">412</FONT>                    });<a name="line.412"></a>
+<FONT color="green">413</FONT>            }<a name="line.413"></a>
+<FONT color="green">414</FONT>        }<a name="line.414"></a>
+<FONT color="green">415</FONT>    }<a name="line.415"></a>
 
 
 



Mime
View raw message