Ask Your Question

Massimo2013's profile - activity

2020-11-24 05:38:54 +0200 received badge  Notable Question (source)
2020-04-19 15:26:02 +0200 received badge  Popular Question (source)
2020-02-14 01:07:25 +0200 received badge  Famous Question (source)
2019-09-07 16:54:57 +0200 received badge  Famous Question (source)
2019-08-03 01:32:26 +0200 received badge  Notable Question (source)
2019-04-09 13:59:36 +0200 received badge  Notable Question (source)
2018-11-13 16:49:10 +0200 received badge  Popular Question (source)
2018-04-12 15:13:37 +0200 received badge  Popular Question (source)
2017-11-22 11:54:07 +0200 received badge  Popular Question (source)
2016-11-04 20:23:56 +0200 commented answer Use cumulative distribution functions

Here is a shortened version of what I did in R, and would like to replicate in sagemath:

x=(0:80)/10
meanl=5/3
sdl=2/3
n <- function(z) { 1-plnorm(z,meanlog=meanl,sdlog=sdl) }
b <- function(z) dlnorm(z, meanlog=meanl, sdlog=sdl)
BB <- function(z) integrate(function(w) w * b(w), lower = z, upper = Inf)$value
B <- Vectorize(BB, vectorize.args='z')
h <- function(x) 40*exp(-x)
plot(x,h(x)+x,ylim=c(0,10),type="l")
lines(x,5-x-n(h(x))*h(x)+B(h(x)),xlim=c(0,max(x)),col=3)
2016-11-04 17:35:35 +0200 received badge  Nice Question (source)
2016-11-04 13:02:15 +0200 commented answer Use cumulative distribution functions

Thanks. However, this does not seem to allow me to use N(x) in an expression as I would do with any other (symbolic) function. For example, I'm not even able to 'plot(1-N,(x,0,10))' This is unfortunate, as I wanted to translate into sagemath a simulation I did in R, where I can use "proper" functions, such as 'plnorm' and 'dlnorm'

2016-11-04 07:01:49 +0200 commented answer Use cumulative distribution functions

But what if I need to use it as/in a symbolic function?

2016-11-03 23:57:25 +0200 asked a question Use cumulative distribution functions

I don't understand how to use cumulative distribution functions in sagemath. For example, I'd like to define a function N(x) as N(x)=1-F(x) where F is a cumulative log-normal distribution However, if I try

 W = RealDistribution('lognormal',[1.5,.6])
 N(x) = W.cum_distribution_function(x)

it does not seem to work at all

2016-10-20 22:02:31 +0200 asked a question Change font size for all texts in a graph

Is it possible to set the font size for all labels in a plot? I have been able to set the font family changing the internal parameters of matplotlib

from matplotlib import rc
rc('text',usetex=True)
rc('font',**{'family':'serif','serif':['Times']})

I'd like to change the size as well, so that all labels created with 'text' are the same size (note that I want to use TeX in labels)

2016-10-20 16:49:07 +0200 received badge  Famous Question (source)
2016-09-18 23:03:39 +0200 commented question SageMath @interact under Jupyter

I've just updated to the 7.3 version of sagemath, and interact does not work under jupyter. Does anybody have the same problem?

2016-09-02 18:58:23 +0200 received badge  Good Question (source)
2016-09-01 09:10:51 +0200 received badge  Notable Question (source)
2016-07-18 13:16:14 +0200 received badge  Notable Question (source)
2016-07-18 13:16:14 +0200 received badge  Popular Question (source)
2016-07-16 18:21:11 +0200 received badge  Popular Question (source)
2016-04-23 19:01:42 +0200 received badge  Supporter (source)
2016-04-23 09:20:36 +0200 commented answer Function with a lower limit

Besides, the function g(x) does not seem to be used correctly by solve: solve([g(x)==y,x==4],[x,y]) gives a negative value for y

2016-04-23 08:57:03 +0200 commented answer Function with a lower limit

You are right: it seems to work with plot(g,x,0,10). However, it does not work properly with plot(g(x),x,0,10) Is there something I'm missing about the working of plot?

2016-04-23 00:10:44 +0200 asked a question Function with a lower limit

I need to define a function like the following:

y = 5 - 2x  if f(x)>0
    0       otherwise

I tried different solutions:

f(x) = 5 - 2*x
g(x) = max(f(x),0)

or:

f(x) = 5 - 2*x
def g(x):
     return f(x) if f(x)>0 else 0

However, when I try to plot them, they do not seem to work: the first ignores the lower bound, while the second is always zero. This is strange, as when I try [g(x) for x in range(0,10)] it returns the correct values of g(x)

2016-04-14 23:07:37 +0200 received badge  Nice Question (source)
2016-04-14 21:13:36 +0200 received badge  Student (source)
2016-04-14 18:51:05 +0200 asked a question SageMath @interact under Jupyter

I'm trying to take advantage of the power of SageMath and the superior efficiency and beauty of Jupyter notebooks. I open locally my notebooks with the command:sagemath -n jupyter. This opens a jupyter notebook with sagemath kernel. However, unfortunately, interaction commands and widgets (slider, select, dropdown) are not fully compatible: under Jupyter I must use ipywidgets, but then the code is not compatible with SageMath, if I want to make it available in SageMathCloud or SageMathCell.

Is there a way to make sagemath @interact commands available to Jupyter? Are there plans to use the same commands and provide a more complete support of SageMath under Jupyter?

2016-04-13 16:19:49 +0200 asked a question Define a function with different cases

I'm working with a function whose functional form is different at a specific value of the parameter (a=1):

 if a==1:
            U(x,L)=log(x)+log(1-L)
 else:
            U(x,L)=(x^(1-a)/(1-a)+(1-L)^(1-a)/(1-a))

Is it possible to define once and for all a function U(x,L,a) which includes the parameter as a variable so that I don't need to redefine it when a = 1?

2015-05-06 20:26:34 +0200 asked a question Solve a system of nonlinear equations

I'm trying to solve the following system of nonlinear equation:

var("x,L,a")
sms = (x/(1-L))^(1-a) == .3
bb = x == .3*L
solve([sms,bb],x,L)

I expect that sage gives me a symbolic solution, the output is the following:

[x == 0.3*L, (-x/(L - 1))^(-a + 1) == 0.3]

As I am a newbie to sage, I wonder if there's something wrong/missing