[sage-support] modulo operator for reals

2010-10-04 Thread jpc
Why does the plot
   plot(k%1,k,0,5)
is not produced but the following works:
  k=var('k')
  plot( k/1, k,0,5).show()
  print 1.9%1

What can be used instead ?

Pedro

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: BoxPlot in Sage: how do we plot?

2010-03-14 Thread jpc
There is matplotlib

http://matplotlib.sourceforge.net/examples/pylab_examples/boxplot_demo.html?highlight=boxplot

http://matplotlib.sourceforge.net/plot_directive/mpl_examples/pylab_examples/boxplot_demo.py

I also didn't get it with R in sage (or python).

Pedro Cruz


On Mar 14, 7:22 am, mo moshea...@gmail.com wrote:
 I don't see a direct command in sage for BoxPlot.
 Thus, I've tried many 'R' versions of boxplot (like: r.bxplot,
 r.bplot, r.boxplot) on a dataset I have, but could not get a plot...
 I am using the latest Sage Notebook (v 4.3.3)
 Would you pls help?

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Simple multiprocessing example in Sage-Notebook

2010-03-07 Thread jpc
I've tried with

print pool.map(f, range(10))

instead of

pool.map(f, range(10))

calling python file.py

In the notebook, the output must be caughted and printed for user, I
think.

Pedro



On Mar 7, 5:23 am, Gokhan Sever gokhanse...@gmail.com wrote:
 Hello,

 I am executing this example in Sage Notebook v4.3.3

 from timeit import default_timer as clock
 from multiprocessing import Pool

 def f(x):
     return x**3 + x**2 + x

 if __name__ == '__main__':
     t1 = clock()
     pool = Pool(processes=2)            # start 2 worker processes
     pool.map(f, range(100));
     t2 = clock()
     print Elapsed time using two processes:, t2-t1

 When I run the code in shell using python file.py I don't get any
 results from function mapping printed out however in Sage-Notebook I
 see a huge output with WARNING: Output truncated!

 Any ideas what might be causing this issue?

 Thanks.

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] json and sage

2010-02-19 Thread jpc
Python json library is of simple use but there's this problem:

sage: import json
sage: json.dumps( {a: 1.8} )
...produce an error because:
sage: x = 1.8
sage: type(x)
type 'sage.rings.real_mpfr.RealLiteral'

Should one do the type cast below for every int or float when using
sage ?

sage: type(float(x))
type 'float'
sage: json.dumps( {a: float(x)} )
'{a: 1.8}'

Any easier way ?

Thank you,
Pedro

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: examples of using R

2010-01-29 Thread jpc
Hi,

I've search on
   http://rpy.sourceforge.net/
and use R with commands inside a Sage script as following:

from sage.all import *

def iunif(a,b):
return Integer(fround(r.runif(1,RDF(a),RDF(b)),0))
def runif(a,b,prec):
return RDF(fround(r.runif(1,RDF(a),RDF(b)),prec))
def rbernoulli():
return r.rbinom(1, 1, 0.5)._sage_()

From Sage I've used RDF because R needs reals and not symbolic
expressions and used _sage_() to convert from R objects to Sage
objects.

I have problems with:
 r.set_seed = accept only one argument
 r graphics = could not got them to appear in Sage environment.

I'm no expert in Sage so I welcome any suggestion to improve the above
commands.

Pedro Cruz



On Jan 29, 4:02 am, Gokhan Sever gokhanse...@gmail.com wrote:
 On Jan 28, 8:00 pm, Ondrej Certik ond...@certik.cz wrote:

  Hi,

  are there some examples how to use R from Sage?

  I tried to search here:

 http://www.sagemath.org/help.html

 http://www.sagemath.org/doc/reference/

  I also tried to search sage-devel, for R and R statistics and R
  statistical, but didn't find anything. So the next time, I'll at
  least find my own message, and hopefully some hints. :)

  Ondrej

 Hi Ondrej,

 A couple sources I can point out:

 http://sage.math.washington.edu/home/mhansen/sage-epydoc/sage.interfa...
 (Interestingly this doesn't show up on the main reference 
 --http://www.sagemath.org/doc/reference/interfaces.html)
 Might need to let SAGE guys know about this, on sage-devel or open a
 documentation enhancement etc. :)

 http://groups.google.com/group/sage-support/browse_thread/thread/53d6...

 Also sage-notebook has an r mode you can directly enter R
 commands.

 y - c(1, 2, 3) instead of y = r(c(1, 2, 3))

 I know it is tricky to search terms like R or C. Python is very
 easy to find although at time it interferes with the snake and
 monthy :)

On Jan 29, 4:02 am, Gokhan Sever gokhanse...@gmail.com wrote:
 On Jan 28, 8:00 pm, Ondrej Certik ond...@certik.cz wrote:

  Hi,

  are there some examples how to use R from Sage?

  I tried to search here:

 http://www.sagemath.org/help.html

 http://www.sagemath.org/doc/reference/

  I also tried to search sage-devel, for R and R statistics and R
  statistical, but didn't find anything. So the next time, I'll at
  least find my own message, and hopefully some hints. :)

  Ondrej

 Hi Ondrej,

 A couple sources I can point out:

 http://sage.math.washington.edu/home/mhansen/sage-epydoc/sage.interfa...
 (Interestingly this doesn't show up on the main reference 
 --http://www.sagemath.org/doc/reference/interfaces.html)
 Might need to let SAGE guys know about this, on sage-devel or open a
 documentation enhancement etc. :)

 http://groups.google.com/group/sage-support/browse_thread/thread/53d6...

 Also sage-notebook has an r mode you can directly enter R
 commands.

 y - c(1, 2, 3) instead of y = r(c(1, 2, 3))

 I know it is tricky to search terms like R or C. Python is very
 easy to find although at time it interferes with the snake and
 monthy :)

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: find_root reports zeroes of denominator as roots

2009-03-16 Thread jpc

Using symbolic computation:

sage: x=var('x')
sage: solve(1/x==0)
[ ]
sage:

However, and like matlab fzero command, the numerical answer of the
equation is $x \approx 0$ because of the change of sign of $1/x \in
[-1,1]$.

Maybe the find_root documentation needs to mention that continuity
of $f$ is necessary.

jpc



On Mar 15, 3:54 am, yacob imya...@gmail.com wrote:
 f(x)=1/x
 r1=find_root(f,-1,1);r1
 -1.8189894035440371e-12

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---