caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] generating random variables
@ 2002-05-09 17:55 Henri Dubois-Ferriere
  2002-05-09 18:22 ` David Chase
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Henri Dubois-Ferriere @ 2002-05-09 17:55 UTC (permalink / raw)
  To: caml-list

[apologies if this is posted twice on the newsgroup; i believe the 
recipients of the mail-list did not get it the first time around]


Hello, 

For some simulation studies,  I need to generate exponential,
gaussian, and poisson random variables. Maybe also some more exotic
ones a little later on.

I have looked around, but did not seem to find any available libraries
for generating random variables (except of course for the uniform
variables in Random). Can anyone point me to such a thing, if it
exists?

Thanks, 

Henri

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] generating random variables
  2002-05-09 17:55 [Caml-list] generating random variables Henri Dubois-Ferriere
@ 2002-05-09 18:22 ` David Chase
  2002-05-09 18:45 ` Olivier Andrieu
  2002-05-10  1:51 ` Shawn Wagner
  2 siblings, 0 replies; 6+ messages in thread
From: David Chase @ 2002-05-09 18:22 UTC (permalink / raw)
  To: Henri Dubois-Ferriere, caml-list

Have you considered

    http://www.taygeta.com/random/gaussian.html

Google found it for me.  I don't know if that is
enough detail for you.

At 07:55 PM 5/9/2002 +0200, Henri Dubois-Ferriere wrote:
>For some simulation studies,  I need to generate exponential,
>gaussian, and poisson random variables. Maybe also some more exotic
>ones a little later on.

David Chase

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] generating random variables
  2002-05-09 17:55 [Caml-list] generating random variables Henri Dubois-Ferriere
  2002-05-09 18:22 ` David Chase
@ 2002-05-09 18:45 ` Olivier Andrieu
  2002-05-10  1:51 ` Shawn Wagner
  2 siblings, 0 replies; 6+ messages in thread
From: Olivier Andrieu @ 2002-05-09 18:45 UTC (permalink / raw)
  To: Henri Dubois-Ferriere; +Cc: caml-list

 Henri Dubois-Ferriere [Thursday 9 May 2002] :
 > I have looked around, but did not seem to find any available
 > libraries for generating random variables (except of course for the
 > uniform variables in Random). Can anyone point me to such a thing,
 > if it exists?

You could use GSL, the GNU scientific library
(http://sources.redhat.com/gsl/). It's written in C of course.

I've made some bindings (not for everything, but the RNGs and random
distributions are working). If you're interested, I can send you the
whole stuff.

      Olivier

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] generating random variables
  2002-05-09 17:55 [Caml-list] generating random variables Henri Dubois-Ferriere
  2002-05-09 18:22 ` David Chase
  2002-05-09 18:45 ` Olivier Andrieu
@ 2002-05-10  1:51 ` Shawn Wagner
  2002-05-10 14:09   ` [Caml-list] Using the O'Caml toplevel inside a C program Emmanuel Chailloux
  2 siblings, 1 reply; 6+ messages in thread
From: Shawn Wagner @ 2002-05-10  1:51 UTC (permalink / raw)
  To: caml-list

On Thu, May 09, 2002 at 07:55:44PM +0200, Henri Dubois-Ferriere wrote:
> [apologies if this is posted twice on the newsgroup; i believe the 
> recipients of the mail-list did not get it the first time around]
> 
> 
> Hello, 
> 
> For some simulation studies,  I need to generate exponential,
> gaussian, and poisson random variables. Maybe also some more exotic
> ones a little later on.
> 
> I have looked around, but did not seem to find any available libraries
> for generating random variables (except of course for the uniform
> variables in Random). Can anyone point me to such a thing, if it
> exists?
> 

My Stew library (Available at http://raevnos.pennmush.org/code/ocaml.html)
includes some random number stuff. There are a few modules for random number
distributions (Functorized so you can use your choice of actual (P)RNG
generators with them; I like the Mersenne Twister, also part of the
library.), and I just added exponential and poisson distributions after
seeing your email. :)

-- 
Shawn Wagner
shawnw@speakeasy.org
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Caml-list] Using the O'Caml toplevel inside a C program
  2002-05-10  1:51 ` Shawn Wagner
@ 2002-05-10 14:09   ` Emmanuel Chailloux
  2002-05-14  8:59     ` Xavier Leroy
  0 siblings, 1 reply; 6+ messages in thread
From: Emmanuel Chailloux @ 2002-05-10 14:09 UTC (permalink / raw)
  To: caml-list



  Hello,

     I try to use the O'Caml toplevel inside a C program but the result 
does not run.

    I wrote the two following programs : g.ml and p.c :

  g.ml
  -------

open Toploop;;
open Callback;;

print_string "apres les open";;
print_newline();;

let exec s =
   let ast = !parse_toplevel_phrase (Lexing.from_string s) in
   ignore(execute_phrase false Format.std_formatter ast);;

let main() =
   print_string "lancement de main (OCAML)";
   print_newline();
  ();;

Callback.register "exec_ocaml" exec;;
Callback.register "main_ocaml" main;;


p.c
----

#include <stdlib.h>
#include <stdio.h>

#include <caml/mlvalues.h>
#include <caml/callback.h>

int main ( int argc, char ** argv ) {
   value v;
   printf("debut de C\n"); fflush(stdout);
   caml_startup(argv);

   printf("init OCAML\n"); fflush(stdout);
   callback(*caml_named_value("main_ocaml"), Val_unit);
   fflush(stdout);

  ...

   v = copy_string("let x = ref 3;;");
   callback(*caml_named_value("exec_ocaml"), v);
   fflush(stdout);
  ...
   return EXIT_SUCCESS;
}


compilation (MacOSX) :
----------------
$ ocamlc -output-obj toplevellib.cma unix.cma g.ml

camlprog.c: In function `caml_startup':
camlprog.c:39186: warning: implicit declaration of function 
`caml_startup_code'

$ cc -I/usr/local/lib/ocaml -L/usr/local/lib/ocaml camlprog.o p.c -lunix 
-lcamlrun

execution (MacOSX, but I obtain the same behaviour with Linux)  :
-------------
  $ ./a.out
debut de C
 >> Fatal error: Toplevel bytecode executable is corrupted
Fatal error: exception Misc.Fatal_error




I suppose that the problem comes from the toploop.ml file in the 
following expression :

---
let _ =
   Sys.interactive := true;
   Symtable.init_toplevel();
   Compile.init_path()
--
but I'am not sure.

  Is there a solution or another way to do that?


Best regards.
Emmanuel Chailloux...

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Using the O'Caml toplevel inside a C program
  2002-05-10 14:09   ` [Caml-list] Using the O'Caml toplevel inside a C program Emmanuel Chailloux
@ 2002-05-14  8:59     ` Xavier Leroy
  0 siblings, 0 replies; 6+ messages in thread
From: Xavier Leroy @ 2002-05-14  8:59 UTC (permalink / raw)
  To: Emmanuel Chailloux; +Cc: caml-list

>      I try to use the O'Caml toplevel inside a C program but the result 
> does not run.

That's a limitation of programs built with -output-obj: the symbol
table information that is normally saved in bytecode executable files
is not available in the C object file generated by -output-obj;
consequently, neither dynamic loading via Dynlink nor the toplevel can
work.

It's not trivial to work around this issue, so I haven't addressed it
yet.

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-05-14  9:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-09 17:55 [Caml-list] generating random variables Henri Dubois-Ferriere
2002-05-09 18:22 ` David Chase
2002-05-09 18:45 ` Olivier Andrieu
2002-05-10  1:51 ` Shawn Wagner
2002-05-10 14:09   ` [Caml-list] Using the O'Caml toplevel inside a C program Emmanuel Chailloux
2002-05-14  8:59     ` Xavier Leroy

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).