While there are a lot of valid ways to do it, anything you do will change the outcome of the probability anyway. I'm assuming you are just looking to clamp the values.<br><br>Try this:<br><br><a href="http://codepad.org/NzlmSMN9">http://codepad.org/NzlmSMN9</a> (it runs the code, too)<br>
<br>==========================================<br># Clamp a normal distribution outcome<br><br>import random<br><br>class applicant():<br>    def __init__(self, x, y):<br>        self.randomnum = clamp(random.normalvariate(x, y), 0, 100)<br>
<br>def clamp(input, min=0, max=100):<br>    """Clamps the input between min and max.<br>    <br>    if  input < min, returns min<br>        min < input < max, returns input<br>        input > max, returns max<br>
        <br>    Default: min = 0, max = 100."""<br>    if input < min:<br>        return min<br>    elif input > max:<br>        return max<br>    else:<br>        return input<br>    <br>if __name__ == "__main__":<br>
    for num in range(10):<br>        print applicant(random.randint(0,100), random.randint(0,100)).randomnum<br>======================================================<br><br>Or you could just use randint() if you only wanted a linear distribution.<br>
<br>PS: Thanks, btw, new to python myself also, and looking into this was cool. :]<br><br>Best regards,<br>
<br clear="all">Ching-Yun "Xavier" Ho, Technical Artist<br><br>Contact Information<br>Mobile: (+61) 04 3335 4748<br>Skype ID: SpaXe85<br>Email: <a href="mailto:contact@xavierho.com" target="_blank">contact@xavierho.com</a><br>
Website: <a href="http://xavierho.com/" target="_blank">http://xavierho.com/</a><br>

<br><br><div class="gmail_quote">On Sat, Jun 20, 2009 at 3:20 PM, Vincent Davis <span dir="ltr"><<a href="mailto:vincent@vincentdavis.net" target="_blank">vincent@vincentdavis.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

I currently have something like this.<br>
<br>
class applicant():<br>
    def __int__(self, x, y):<br>
        self.randomnum = normalvariate(x, y)<br>
then other stuff<br>
<br>
x, y are only used to calculate self.randomnum   and this seems to<br>
work. But I want self.randomnum to be 0 <= randomnum <= 100. The only<br>
way I can thing of to do this is is with a while statement and that<br>
seems more complicated than necessary. I would really like to keep it<br>
on one line. How would I do that?<br>
<br>
Thanks<br>
Vincent Davis<br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>