On 2012-10-21, LFS <[email protected]> wrote:
> ------=_Part_948_19630829.1350808455726
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hiya guys!
> I have a function:
> def GDD(num,P):
> D=GeneralDiscreteDistribution(P)
> D.reset_distribution()
> L=[D.get_random_element() for _ in range(num)]
> return L
>
> and then commands
> P=[0.5,0.33, 0.17]
> L=GDD(num,P)
>
> I am definitely not getting random distributions within my lists L (i.e.
> the same lists repeat themselves much too often).
> Am I not understanding something here?
Sage, as (almost?) any other system, only gets you pseudorandom numbers,
i.e. a sequence that is deterministic (from a given random seed you
always get the same sequence), but looks like a random one.
D.reset_distribution() restarts the sequence from a default random seed.
Now you will always get the same segment of the sequence!
To fix it, you need e.g. to change the function GDD to accept D as a
parameter:
def GDDinit(P):
D=GeneralDiscreteDistribution(P)
D.reset_distribution()
return D
def GDD(num,D):
L=[D.get_random_element() for _ in range(num)]
return L
D=GDDInit([0.5,0.33, 0.17])
L1=GDD(10,D)
L2=GDD(10,D)
Now your L1 and L2 should not correlate much...
HTH,
Dmitrii
> Thanks for any help.
>
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/sage-support?hl=en.