From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id BA72DBBC4 for ; Thu, 16 Apr 2009 11:25:53 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApgDAIeW5kmBrw8EgWdsb2JhbACNJoh+AQEWIrl6g30G X-IronPort-AV: E=Sophos;i="4.40,197,1238968800"; d="scan'208";a="24676959" Received: from ext.lri.fr ([129.175.15.4]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 16 Apr 2009 11:25:53 +0200 Received: from localhost (localhost [127.0.0.1]) by ext.lri.fr (Postfix) with ESMTP id 7FC02A4414; Thu, 16 Apr 2009 11:25:53 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at lri.fr Received: from ext.lri.fr ([127.0.0.1]) by localhost (ext.lri.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id g-F7UDR5nY7M; Thu, 16 Apr 2009 11:25:53 +0200 (CEST) Received: from [129.175.4.103] (lri4-103 [129.175.4.103]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ext.lri.fr (Postfix) with ESMTP id 63894A4245; Thu, 16 Apr 2009 11:25:53 +0200 (CEST) Message-ID: <49E6F9A1.3050302@lri.fr> Date: Thu, 16 Apr 2009 11:25:53 +0200 From: Cedric Auger User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: Andrey Riabushenko Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Functional unparsing References: <200904152341.28121.cdome@bk.ru> In-Reply-To: <200904152341.28121.cdome@bk.ru> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Spam: no; 0.00; lri:01 unparsing:01 ocaml:01 unparsing:01 printf:01 printf:01 beginner's:01 ocaml:01 bug:01 ocamllex:01 ocamlyacc:01 syntax:01 ocamllex:01 ocamlyacc:01 paris-sud:01 Andrey Riabushenko a écrit : > Hi ocaml developers, > > I am currently developing a library for multivariate regressions including > linear, nonlinear, generalized, weighted and so on. In my opinion most the > convenient interface is the one described further and is based on functional > unparsing. > > Something like that: > > Stats.linear_regression "y ~ x1 exp(x2) log(x3) x3^2" > Returns float -> float -> float -> float -> regression_result = > > Stats.generalized_regression "log(y) ~ x1 x^2 log(x3) " > Returns float -> float -> float -> float -> regression_result = > > For time series: > Stats.ts_regression "y ~ ARMA(5,3)" > Stats.ts_regression "y ~ ARMA(2,2) GARCH(2,1)" > > > If want to ask you two questions. > 1. Do you find such interface convenient? Critique is welcome. If you have > better idea, please tell me. I will make all publicly available. > I don't know what is really itended, but I think implementing something like " let double x = 2 *. x in Stats.linear_regression "y ~ double x1"" will be painfull, since you need to parse the string according to the environnement. The solution " let double x = 2 *. x in Stats.linear_regression "y ~ %1 x1" double" closer to printf and format %1 meaning "float -> float" is easier to implement, but less readable. If you don't require custom function, what you think should do the trick and seems to be manageable, but maybe that will be awfull to repeat many times the same function in case of use in different places. > 2. The second question regarding function unparsing. I haven't used this > technique before. Are there some docs, blog articles, descriptions and etc? > The only relevant documentation I have found is printf.ml :). Might someone > have a minimal working example to demonstrate? > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > You can also take a look in format.ml, but it will be more complicate. I don't know if it is a good idea, but if your expressions are complicate, try to use ocamllex and ocamlyacc. Another thing, printf is simplistic in the syntax of the string, that is you only have text and no complicate expression to type (we can printf "x log () / 0"), but complicate in managing formatters you don't need (printf "it is %s o clock" time) with your examples (you have no parameter); from this point of view, ocamllex and ocamlyacc may be more relevant (and are well documented). -- Cédric AUGER Univ Paris-Sud, Laboratoire LRI, UMR 8623, F-91405, Orsay