ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 22 Mar 2023 16:22:41 +0100Error in listing a Ziphttps://ask.sagemath.org/question/67023/error-in-listing-a-zip/
Until the end of this code all is fine
billes=[ZZ.random_element(0, 4) for i in range(50)]
billes+=[ZZ.random_element(5, 10) for i in range(80)]
billes+=[ZZ.random_element(10, 25) for i in range(21)]
billes+=[ZZ.random_element(25, 50) for i in range(28)]
billes+=[ZZ.random_element(50, 100) for i in range(28)]
shuffle(billes)#no necessary here only to confirm
billes1=sorted(billes)
binbilles1=[[x for x in billes1 if 0 <= x < 4],[x for x in billes1 if 5 <= x < 10],[x for x in billes1 if 10 <= x < 25],[x for x in
billes1 if 25 <= x < 50],[x for x in billes1 if 50 <= x < 100]]
avbinbilles1=[len(x)^(-1)*sum(x) for x in binbilles1]
number=[len(x) for x in binbilles1]
cumsumpop=[sum(number[:i]) for i in range(1, len(number)+1)]
percumsumpop=[0]+[sum(number[:i])/sum(number) for i in range(1, len(number)+1)]
cumsumavbinbilles1=[sum(avbinbilles1[:i]) for i in range(1, len(avbinbilles1)+1)]
percumsumavbinbilles1=[0]+[sum(avbinbilles1[:i])/sum(avbinbilles1) for i in range(1, len(avbinbilles1)+1)]
#percumbilles1=[0]+[sum(binbilles1[:i])/sum(number) for i in range(1, len(binbilles1)+1)]
bool(len(percumsumavbinbilles1)==len(percumsumpop))
To plot a Lorenz curve I add
A=list(zip(percumsumavbinbilles1,percumsumpop))
as show by `If you meant to plot two lists 'x' and 'y' against each other, use 'list_plot(list(zip(x,y)))'` in `https://doc.sagemath.org/html/en/reference/plotting/sage/plot/plot.html`
But this generate an error `'list' object is not callable`. Could somebody explain my mistake?
CyrilleWed, 22 Mar 2023 16:22:41 +0100https://ask.sagemath.org/question/67023/How to make "zip" work faster?https://ask.sagemath.org/question/26790/how-to-make-zip-work-faster/ I have these two finite sets $A$ and $B$ where the size of $A$ is typically much larger than the size of $B$. (typically $|A| is 200-500$ and $|B| is 10-50$) I am trying to enumerate all possible maps from $B$ to $A$ using the following idea - but this turns out to be very slow.
- Is there a way to speed this up?
- Without the over all "for i" loop can I access any one of the "k"s?
(for every i each $l$ is a list of tuples)
How can I just pick out any one such "k" list without wanting to wait for the whole code to run.
S = []
from itertools import product
for i in product(A,repeat = len (B)):
k = zip(B,i)
S.append(k)
show(S)PhoenixSun, 10 May 2015 23:42:04 +0200https://ask.sagemath.org/question/26790/How do I extract/unpack the zip filehttps://ask.sagemath.org/question/8108/how-do-i-extractunpack-the-zip-file/I have down loaded the file sage-vmware-4.6.zip fom UK mirror.
When I try to open it (expand) I get the message "file invalid or corrupted" and of course nothing happens.
How do get to install this software ? etrcMon, 09 May 2011 09:20:58 +0200https://ask.sagemath.org/question/8108/