Thank you. I think `random-natural` works for my case.
'Paulo Matos' via Racket Users 于2019年4月2日周二
上午12:49写道:
> Check the math library by Neil Toronto:
>
> https://docs.racket-lang.org/math/base.html?q=random#%28part._.Random_.Number_.Generation%29
>
> (random-natural k) → Natural
>
>
Thank you very much. This is exactly what I needed.
Gustavo Massaccesi 于2019年4月3日周三 下午2:22写道:
> The implementation is tricky, but you can understand the distribution
> looking at this "alternative" implementation:
>
> (define (myrandom)
> #;(/ (+ (random 4294967087) 1) (+ 4294967087 1))
>
The implementation is tricky, but you can understand the distribution
looking at this "alternative" implementation:
(define (myrandom)
#;(/ (+ (random 4294967087) 1) (+ 4294967087 1))
(* (+ (random 4294967087) 1) 2.328306549295728e-10))
[it may have a tiny rounding difference]
Gustavo
I
I'll also throw my hat in the ring with handy/test-more, which I'm in the
process of breaking out into a separate module but have not yet found the
tuits to finish.
It takes a different approach than rackunit: Tests always have output
regardless of whether they succeed or fail. Running a differe
If you want your tests to catch exceptions you need to wrap them in
exception handlers, which you could write a macro to do for you; as Eric
noted though you need to be careful to preserve source locations.
These kinds of issues (error messages and managing source locations when
using macros) l
If you are implementing random number generators, you may want to use a
test suite:
Tu01 http://simul.iro.umontreal.ca/testu01/tu01.html
or
Dieharder https://webhome.phy.duke.edu/~rgb/General/rand_rate/rand_rate.abs
Hope this helps,
Evelyn Mitchell
efmph...@gmail.com
On Tue, Apr 2, 2019 at 12:55
> #lang racket/base
> (define f (λ _ (error 'FAIL)))
> (module+ test
> (require rackunit)
> (define OK (string->unreadable-symbol "OK"))
> (define-syntax-rule (check-OK-form expr)
> (let ([val expr])
> (with-check-info (['input 'expr] ['expected OK] ['actual val])
> (check
>
> > Are you using emacs racket-mode?
>
> I am, almost exclusively. Exception and check failure locations can be a
> pain, but they work in general.
>
What Eric said :) But when in doubt I always compare behavior with DrRacket
and raco, and racket-mode stands tall here and does at least what
8 matches
Mail list logo