{"action":"created","issue":{"url":"https://api.github.com/repos/odinsbane/least-squares-in-java/issues/1","repository_url":"https://api.github.com/repos/odinsbane/least-squares-in-java","labels_url":"https://api.github.com/repos/odinsbane/least-squares-in-java/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/odinsbane/least-squares-in-java/issues/1/comments","events_url":"https://api.github.com/repos/odinsbane/least-squares-in-java/issues/1/events","html_url":"https://github.com/odinsbane/least-squares-in-java/issues/1","id":137272674,"number":1,"title":"Could I use this lib to solve my problem?","user":{"login":"timmolter","id":738972,"avatar_url":"https://avatars.githubusercontent.com/u/738972?v=3","gravatar_id":"","url":"https://api.github.com/users/timmolter","html_url":"https://github.com/timmolter","followers_url":"https://api.github.com/users/timmolter/followers","following_url":"https://api.github.com/users/timmolter/following{/other_user}","gists_url":"https://api.github.com/users/timmolter/gists{/gist_id}","starred_url":"https://api.github.com/users/timmolter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timmolter/subscriptions","organizations_url":"https://api.github.com/users/timmolter/orgs","repos_url":"https://api.github.com/users/timmolter/repos","events_url":"https://api.github.com/users/timmolter/events{/privacy}","received_events_url":"https://api.github.com/users/timmolter/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-02-29T14:40:11Z","updated_at":"2016-02-29T15:31:21Z","closed_at":null,"body":"Hi, Just asking for your opinion if this lib would suffice for my specific problem. I looked at <https://github.com/odinsbane/least-squares-in-java/blob/master/src/test/java/org/orangepalantir/leastsquares/fitters/NonLinearSolverTest.java>, but I am still wondering. I posted my problem on StackOverflow and one comment led me here: \r\n\r\n<http://stackoverflow.com/q/35701194/1625820>"},"comment":{"url":"https://api.github.com/repos/odinsbane/least-squares-in-java/issues/comments/190257836","html_url":"https://github.com/odinsbane/least-squares-in-java/issues/1#issuecomment-190257836","issue_url":"https://api.github.com/repos/odinsbane/least-squares-in-java/issues/1","id":190257836,"user":{"login":"odinsbane","id":3462801,"avatar_url":"https://avatars.githubusercontent.com/u/3462801?v=3","gravatar_id":"","url":"https://api.github.com/users/odinsbane","html_url":"https://github.com/odinsbane","followers_url":"https://api.github.com/users/odinsbane/followers","following_url":"https://api.github.com/users/odinsbane/following{/other_user}","gists_url":"https://api.github.com/users/odinsbane/gists{/gist_id}","starred_url":"https://api.github.com/users/odinsbane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odinsbane/subscriptions","organizations_url":"https://api.github.com/users/odinsbane/orgs","repos_url":"https://api.github.com/users/odinsbane/repos","events_url":"https://api.github.com/users/odinsbane/events{/privacy}","received_events_url":"https://api.github.com/users/odinsbane/received_events","type":"User","site_admin":false},"created_at":"2016-02-29T15:31:21Z","updated_at":"2016-02-29T15:31:21Z","body":"```\r\nimport org.orangepalantir.leastsquares.Fitter;\r\nimport org.orangepalantir.leastsquares.Function;\r\nimport org.orangepalantir.leastsquares.fitters.NonLinearSolver;\r\n\r\nimport java.util.Arrays;\r\n\r\n/**\r\n */\r\npublic class JunkClass {\r\n    static double a = 1;\r\n    static double b = 1;\r\n    static double c = 1;\r\n    static double d = 1;\r\n    static double e = 1;\r\n\r\n    static double x = 0.5;\r\n    static double y = 0.1;\r\n    static double z = 1.0;\r\n    public static void main(String[] args){\r\n\r\n        double[][] xs = {{-1}, {0}, {1}};\r\n\r\n        double[] zs = {z, x, y};\r\n\r\n        double r = Math.sqrt(x*x + y*y);\r\n        final double sinTheta0 = x/r;\r\n        final double cosTheta0 = y/r;\r\n\r\n\r\n        Function f = new Function(){\r\n\r\n            @Override\r\n            public double evaluate(double[] values, double[] parameters) {\r\n                double t1 = parameters[0];\r\n                double t2 = parameters[1];\r\n                if(values[0] == -1){\r\n                    return a - e + b*Math.cos(t1) + c*Math.sin(t1) + d*Math.cos(t2)*Math.sin(t1) + d*Math.sin(t2);\r\n\r\n                } else if(values[0]==0){\r\n                    return ( b*Math.sin(t1) + c*Math.cos(t1) + d*Math.cos(t2)*Math.cos(t1))*sinTheta0;\r\n                } else{\r\n                    return ( b*Math.sin(t1) + c*Math.cos(t1) + d*Math.cos(t2)*Math.cos(t1))*cosTheta0;\r\n                }\r\n            }\r\n\r\n            @Override\r\n            public int getNParameters() {\r\n                return 2;\r\n            }\r\n\r\n            @Override\r\n            public int getNInputs() {\r\n                return 1;\r\n            }\r\n        };\r\n\r\n        Fitter fit = new NonLinearSolver(f);\r\n        fit.setData(xs, zs);\r\n        double[] params = {0,0};\r\n        fit.setParameters(params);\r\n\r\n        fit.fitData();\r\n\r\n        System.out.println(Arrays.toString(fit.getParameters()));\r\n\r\n\r\n\r\n    }\r\n\r\n    private static double square(double v) {\r\n        return v*v;\r\n    }\r\n}\r\n\r\n```\r\n\r\nI did not check the results."}}