Hello Monks, may the peace of computing be with you,

I'm looking for some new syntax for a script that calculates conjunctions based on the ephemera as provided by the good people at fourmilab. As it is now, I find myself making static calls to a median function which causes execution to follow the same course every time. This is boring the heck out of me and does not allow me to see how things run under slightly-differing scenarios.

What follows are the call and subroutine.

my $guess = median( $upper, $lower ); say "guess is $guess"; sub median { my ( $up, $low ) = @_; my $return = ( $up + $low ) / 2.0; return $return; }

I seek to re-write these as being "close to half" as opposed to half.

I've seen treatments of perl that generate domains using ellipses, but I seek one on the reals. These are represented in perl logic by floats.

The first routine I would like to define is one that returns a float on a uniform interval between .4 and .6, generated stochastically. The other one I seek is a similar such with a normal distribution.

Thank you for your comment,


In reply to subroutines for close to half by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.