ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 10 Jan 2019 14:33:00 -0600Expected value of random variableshttp://ask.sagemath.org/question/44997/expected-value-of-random-variables/ I'm new to SAGE and just getting my feet wet. Would greatly appreciate if someone could point me to how to calculate the following using SAGE:
Say I have an event drawn from a Poisson distribution that happens on average once a year. I'd like to define a random variable and then calculate the following:
1. Probability the event will occur after 1 month (1/12th of a year)
2. Probability the event will not occur for 2 years but will occur during the third year.
I've searched unsuccessfully for how to do this and would greatly appreciate any help.kyesledgeThu, 10 Jan 2019 14:33:00 -0600http://ask.sagemath.org/question/44997/Conversion from symbolic expression to polynomial stuckhttp://ask.sagemath.org/question/44302/conversion-from-symbolic-expression-to-polynomial-stuck/I have a very long symbolic expression with six variables:
> (E_mu, E_xi3, ISP, T, V_mu, V_xi3, Z,
> m, mu, n_I, n_P, xi_1, xi_3)
I call the expression AN. I want to convert it in a polynomial of two variables (mu and xi_3). I tried the following command:
AP = AN.polynomial(None,ring=SR['mu,xi_3'])
This works for simple expressions but the command remains stuck for the given expression. My aim is to get the monomials of the polynomial. mu and xi_3 are random variables and I want to compute the expectation of AN (E[AN]). Thus, I could substitute the expectations in the expression.
AN is a numerator, so it is not a fraction. Moreover, I also tried simply_rational but it did not help to convert.
Is there anyway to convert easily ?
EDIT : [I put the symbolic expression in a framabin.](https://framabin.org/p/?2417942055fc9fc9#Oenpb+BI567QXYcVCzjO4zkLRC0byQaNdhi2XW/CUkY=)borostackFri, 16 Nov 2018 05:53:39 -0600http://ask.sagemath.org/question/44302/Help finding expected value of sum of random variableshttp://ask.sagemath.org/question/32739/help-finding-expected-value-of-sum-of-random-variables/I'm very much a Sage newbie, and I'm having trouble solving for the expected value of a discrete summation. I'll admit that I'm well removed from statistics, linear algebra, and econometrics, so it might be that what I'm trying to accomplish is illogical.
Consider the following parameters:
<b>E</b> ~ N(0,1) (i.e., E is a random variable distributed standard normal)
<b>M</b> ~ U(1,*m*) (i.e., M is a uniformly distributed random variable varying between 1 and *m*)
<b>A</b> = | Σ E×M | over the interval (1,N) (or the absolute value of the summation of E times M over interval 1,N)
I'd like to find the expected value of A as a function of N (or the limit of A as N goes to infinity, assuming A converges to a real number). Can I use Sage to solve for something like this (assuming it's solvable, which I think it is based on some simulation results)?
gsu2014Tue, 08 Mar 2016 11:45:16 -0600http://ask.sagemath.org/question/32739/Symbolic expectations and double integralshttp://ask.sagemath.org/question/8648/symbolic-expectations-and-double-integrals/I'd like to compute the following expectation ($U$ and $V$ are independent and normally distributed or Gaussian)
$a_{k,p}=E(|U|^p|U+\sqrt{k-1}V|^p)$
Is there a way to directly compute those expectations in Sage ?
If I write it down, I obtain a double integral which I already tried to compute with maxima like this (ok here, you can only see the starting point with the inner integral with respect to $v$ first)
load(distrib);
n(x):=pdf_normal(x, 0, 1);
inner_integral: integrate(abs(u+sqrt(k-1)*v)^p*n(v), v, minf, inf);
but to no avail.
NB: The absolute central moment $a_{1,p/2}$ can be easily obtained with maxima with
ratsimp(integrate(abs(x)^p*n(x), x, minf, inf));
but no 'simple' expression as for the aforementioned double integral.
Any hint?Green diodSat, 21 Jan 2012 02:07:56 -0600http://ask.sagemath.org/question/8648/