1 | initial version |
Not every R function is sent to the Sage namespace (which is good, since otherwise), in particular rbinom
is not available directly, you have to specify that wou want to use this function from the r
interface by typing r.rbinom
instead:
sage: x = r.rbinom(1000,1,.5)
sage: x
[1] 0 1 1 0 1 1 0 0 1 0 0 1 1 1 0 0 1 1 1 1 1 0 1 1 1 0 1 1 1 0 0 1 1 1 0 0 0 1 0 0 1 1 1 1 0 1 1
[48] 0 1 0 1 0 1 0 1 0 1 0 0 0 0 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 0 0 0 0 1 0 0 0 0 0 1 0 1 1 0 0 1 1
[95] 1 0 1 1 1 0 0 0 0 1 1 1 0 0 1 0 1 1 0 1 1 0 1 0 1 1 1 1 0 1 0 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 1
[142] 0 0 0 0 1 0 0 0 0 0 1 0 0 1 1 0 0 1 1 0 1 1 0 0 1 1 1 0 0 0 0 1 1 1 1 1 1 0 1 1 1 0 1 1 0 0 0
[189] 0 1 1 0 1 1 1 1 0 1 1 0 0 1 1 0 1 1 1 1 1 0 0 1 0 1 1 0 0 0 1 1 0 0 1 0 1 1 1 1 0 1 1 1 1 0 1
[236] 0 1 1 1 1 0 0 1 1 0 1 1 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 0 0 0 0 1 0 1 1 1 1
[283] 0 0 0 0 0 0 1 1 0 0 1 1 1 1 1 0 0 1 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 1 0 0 0
[330] 0 0 0 1 1 1 1 0 1 1 1 0 1 0 1 1 0 1 1 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1
[377] 1 0 1 1 0 0 1 0 0 0 1 0 0 1 1 1 1 0 1 1 1 1 0 1 1 1 0 0 1 0 0 1 1 1 0 0 0 1 0 1 0 0 0 1 0 0 0
[424] 0 1 1 1 1 0 0 0 0 1 0 1 0 0 0 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0 1 1 0 0 1 0 0 0 0
[941] 1 1 1 1 0 1 0 1 1 1 0 1 0 1 1 1 0 0 1 1 1 0 1 0 1 0 0 1 1 1 0 1 1 1 0 1 1 0 1 0 1 1 1 1 1 1 0
[988] 1 1 0 0 0 0 1 0 0 0 1 1 1
sage: sum(x)
[1] 508
If you want to use it many times and do not want to use the r.rbinom
, you can always do:
sage: rbinom=r.rbinom
2 | No.2 Revision |
Not every R function is sent to the Sage namespace (which is good, since otherwise), namespace, in particular rbinom
is not available directly, you have to specify that wou want to use this function from the r
interface by typing r.rbinom
instead:
sage: x = r.rbinom(1000,1,.5)
sage: x
[1] 0 1 1 0 1 1 0 0 1 0 0 1 1 1 0 0 1 1 1 1 1 0 1 1 1 0 1 1 1 0 0 1 1 1 0 0 0 1 0 0 1 1 1 1 0 1 1
[48] 0 1 0 1 0 1 0 1 0 1 0 0 0 0 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 0 0 0 0 1 0 0 0 0 0 1 0 1 1 0 0 1 1
[95] 1 0 1 1 1 0 0 0 0 1 1 1 0 0 1 0 1 1 0 1 1 0 1 0 1 1 1 1 0 1 0 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 1
[142] 0 0 0 0 1 0 0 0 0 0 1 0 0 1 1 0 0 1 1 0 1 1 0 0 1 1 1 0 0 0 0 1 1 1 1 1 1 0 1 1 1 0 1 1 0 0 0
[189] 0 1 1 0 1 1 1 1 0 1 1 0 0 1 1 0 1 1 1 1 1 0 0 1 0 1 1 0 0 0 1 1 0 0 1 0 1 1 1 1 0 1 1 1 1 0 1
[236] 0 1 1 1 1 0 0 1 1 0 1 1 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 0 0 0 0 1 0 1 1 1 1
[283] 0 0 0 0 0 0 1 1 0 0 1 1 1 1 1 0 0 1 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 1 0 0 0
[330] 0 0 0 1 1 1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