Some questions on pow and random

Jason Swails jason.swails at gmail.com
Sun Mar 27 06:47:43 EDT 2011


2011/3/27 joy99 <subhakolkata1234 at gmail.com>

> Dear Group,
>
> I have two questions one related to pow() and other is related to
> random.
> My questions are as below:
>
> (i) By standard definition of Likelihood Estimation, we get if x EURO X,
> where X is a countable set of types, p is probability and f is
> frequency.
> L(f;p)=Πp(x)f(x)
>
> My question is python provides two functions,
> (a)     pow for power.
> (b)     reduce(mul, list)
>
> Now, how to combine them? If any one can suggest any help?
> As p(x)f(x), would be huge would pow support it?
>

Not quite sure what you mean by "combine".  p(x)f(x) implies multiplying to
me, but "combine" suggests you mean something like p(f(x)) or the like.  In
any case, as long as the returned result of one of the functions is a valid
argument for the other, you can use the second approach.  And as long as the
results of both functions can be multiplied together (i.e. that operation is
defined), you can do that as well.

At most, pow would be limited by the floating point number in python.
sys.float_info gives me the following:

>>> sys.float_info
sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308,
min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15,
mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)

So if the numbers may be bigger than 1.8e+308, then you'll need to find an
alternative way of doing this.  May I suggest recasting the problem using
only logs if possible (since that will increase the value of the digits that
can be used up to 10 ^ (1.8 E 308).  You can of course always back out the
full value afterwards.


> (b) Suppose we have two distributions p(x1) and p(x2), of the Model M,
> the E of EM algorithm, without going into much technical details is,
> P0(x1,x2), P1(x1,x2) ....
>
> Now I am taking random.random() to generate both x1 and x2 and trying
> to multiply them, is it fine? Or should I take anything else?
>
>
I see no reason why you can't multiply them...  I'm not exactly sure what
you're trying to get here, though.

--Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110327/bcbfb7e2/attachment.html>


More information about the Python-list mailing list