caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Cedric Auger <Cedric.Auger@lri.fr>
To: Andrey Riabushenko <cdome@bk.ru>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Functional unparsing
Date: Thu, 16 Apr 2009 11:25:53 +0200	[thread overview]
Message-ID: <49E6F9A1.3050302@lri.fr> (raw)
In-Reply-To: <200904152341.28121.cdome@bk.ru>

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 = <fun>
>
> Stats.generalized_regression "log(y) ~ x1 x^2 log(x3) " 
> Returns float -> float -> float -> float -> regression_result = <fun>
>
> 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


      parent reply	other threads:[~2009-04-16  9:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-15 20:41 Andrey Riabushenko
2009-04-15 21:21 ` [Caml-list] " Daniel Bünzli
2009-04-15 21:40 ` Hezekiah M. Carty
2009-04-17  8:36   ` Andrey Riabushenko
2009-04-16  9:25 ` Cedric Auger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49E6F9A1.3050302@lri.fr \
    --to=cedric.auger@lri.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=cdome@bk.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).