First time here? Check out the FAQ!

Ask Your Question
1

Use R result

asked 7 years ago

dg.aragones gravatar image

updated 7 years ago

Hi!

I'm new in Sagemath, but I've some experience using R. For example, if I want to generate 100 random numbers from a Bernoulli distribution, I can use the code:

r.rbinom(n=100,size=1,prob=0.25)

But... Is there any way to use the result for another operation in Sagemath? And results related to a linear regression, a given test or a plot (done with R)? May it be more efficient to use Scipy in a general workflow?

Thanks for your answers!

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 7 years ago

tmonteil gravatar image

updated 7 years ago

In this case, you can just call the sage method:

sage: a = r.rbinom(n=100,size=1,prob=0.25)
sage: a
  [1] 0 0 0 1 1 0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0 0 0 1 0 1 1 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0
 [48] 0 0 0 0 0 0 0 0 1 1 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1
 [95] 0 0 1 0 0 0
sage: L = a.sage()
sage: L
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 7 years ago

Seen: 686 times

Last updated: Jan 15 '18