Ask Your Question

QuantLabId's profile - activity

2019-03-12 21:13:50 +0100 received badge  Notable Question (source)
2019-03-12 21:13:50 +0100 received badge  Popular Question (source)
2016-03-31 11:01:45 +0100 received badge  Famous Question (source)
2014-05-18 04:07:57 +0100 received badge  Notable Question (source)
2013-04-10 00:33:50 +0100 received badge  Popular Question (source)
2012-06-11 22:48:13 +0100 marked best answer student t pdf

I don't think we're going to be able to fix this very easily at all. The problem is Maxima's framework, which there has been much discussion about and which is not going to change.

(%i5) assume(n>0);
(%o5)                               [n > 0]
(%i6) display2d:false;

(%o6) false
(%i7) integrate(sqrt(s/n)*1/sqrt(2*pi)*exp(-s*t^2/(2*n))*exp(-s/2)*s^(n/2-1)/(gamma(n/2)*2^(n/2)),s,0,inf);

Is (n+1)/2 an integer?

(%o7) gamma(n/2+1/2)*2^(-n/2-1/2)*(t^2/(2*n)+1/2)^(-n/2-1/2)
(%i8) integrate(sqrt(s/n)*1/sqrt(2*pi)*exp(-s*t^2/(2*n))*exp(-s/2)*s^(n/2-1)/(gamma(n/2)*2^(n/2)),s,0,inf);

Is (n+1)/2 an integer?

Is n an integer?

(%o8) gamma(n/2+1/2)*2^(-n/2-1/2)*(t^2/(2*n)+1/2)^(-n/2-1/2)

Don't even ask about why it asks if n is an integer when it knows (n+1)/2 is an integer; Maxima itself acknowledges that its assumption framework is weak, and of course every open source project has limited resources to fix big architectural issues like that. I don't think it would be trivial for them to fix that.

As for Sage, assuming n is an integer will help a little, but only so much.

(%i9) declare(n,integer);

(%o9) done
(%i10) integrate(sqrt(s/n)*1/sqrt(2*pi)*exp(-s*t^2/(2*n))*exp(-s/2)*s^(n/2-1)/(gamma(n/2)*2^(n/2)),s,0,inf);

Is (n+1)/2 an integer?

(%o10) gamma(n/2+1/2)*2^(-n/2-1/2)*(t^2/(2*n)+1/2)^(-n/2-1/2)

(%i11) declare((n+1)/2,integer);

declare: improper argument: (1+n)/2
 -- an error. To debug this try: debugmode(true);

So we wouldn't even be able to try that, even if we wanted to; Maxima only lets "atoms" be declared to be something (i.e., variables), though we can assume positive or negative about them. And even though the answers are the same, many have pointed out that going through a decision tree of this kind and trying to check that can be arbitrarily computationally expensive, if it's even possible.

I'm sorry, but this is something at the core of how Maxima does business. On the plus side, the answer works nicely enough that one gets from Maxima, and you could use it in Sage.

2012-06-08 03:06:19 +0100 commented question student t pdf

The problem is I want the integration for general n(positive integer), not for some specific n=3 or 5!

2012-06-08 03:01:49 +0100 commented answer student t pdf

Thank you for the answer. But the full solution should be f(t,n). we could consider f(t,n) from f(t,1), f(t,2), f(t,3)... but it's not the exact solution!!!

2012-06-07 08:08:11 +0100 commented answer student t pdf

Yes, it works! But what about when n is an even integer? It also has solution when n is an even number, which is of course p.d.f of t-distribution!

2012-06-07 06:44:14 +0100 asked a question student t pdf

Here's a code for student t pdf.

var("s n t")
assume(n, 'integer')

And it says, TypeError: Computation failed since Maxima requested additional constraints (try the command 'assume(n+1)/2>0)' before integral or limit evaluation, for example): Is (n+1)/2 an integer?

The funny thing is when I add n=5 or n=3, there's no error!

var("s n t")
assume(n, 'integer')

Could any one help me about this?

EDIT : Actually, I tried this on MATHLAB to fail.

   My last hope would be Mathematica? says it's timed out!
2012-04-13 07:37:50 +0100 asked a question A possible error?

Firstly, I defined normal distribution density function

sage: def n_d(mean, variance, x): return 1/(sqrt(2pivariance))exp(-1/2(x-mean)^2/variance)

and I tried to double integrate the joint density function n_d*n_d

sage: integrate(integrate(n_d(mean_x,var_x,x)n_d(beta_1x+beta_0,var_e, y),x,-oo,oo),y,-oo,oo)

first n_d is normal distribution of x second n_d is conditional normal distribution on x, which is normal distribution of y

and it came out as not 1

the result was

sage: 1/2sqrt(2beta_1^2var_x + 2var_e)sqrt(2)/sqrt(beta_1^2var_x +var_e)

What could possibly be wrong?

2012-04-12 02:44:18 +0100 received badge  Scholar (source)
2012-04-12 02:44:18 +0100 marked best answer Can I get a exact solution for SVD?

Note that the type of output depends on the base ring of the matrix, for example a floating point (double) matrix

sage: matrix(RDF,[[1/2,-1/4],[-1/2,1/3]]).eigenvalues()
[0.779908245295, 0.0534250880383]

yields a floating-point result. A matrix over the rationals

sage: matrix(QQ,[[1/2,-1/4],[-1/2,1/3]]).eigenvalues()
[0.05342508803827721?, 0.779908245295057?]

returns eigenvalues in the splitting field which uses interval arithmetic. For arbitrary precision floating point numbers, there is no special implementation,

sage: matrix(RR,[[1/2,-1/4],[-1/2,1/3]]).eigenvalues()
/home/vbraun/opt/sage-5.0.beta11/local/bin/sage-ipython:1: UserWarning: Using generic algorithm for an inexact ring, which will probably give incorrect results due to numerical precision issues.
  #!/usr/bin/env python
[0.779908245295056, 0.0534250880382772]

so Sage falls back to the lapack implementation which doesn't track precision. Finally, over the symbolic ring

sage: matrix(SR,[[1/2,-1/4],[-1/2,1/3]]).eigenvalues()
[-1/12*sqrt(19) + 5/12, 1/12*sqrt(19) + 5/12]

Sage computes the symbolic answer.

Now to your question, nobody has implemented SVD for matrices with base field other than floating point numbers (the only implementation is via lapack). Probably because the real utility of the SVD is that there are efficient numerical ways to compute it, while the symbolic answer is almost always going to be a huge mess of roots.

A possible project would be to implement SVD for more base fields, for example starting with the explicit formula for 2x2 matrices.

2012-04-12 02:44:18 +0100 received badge  Supporter (source)
2012-04-07 10:54:08 +0100 received badge  Editor (source)
2012-04-07 10:53:22 +0100 asked a question Can I get a exact solution for SVD?

Here's an example.

A=matrix(RDF,2,2,[1/2,-1/2,-1/2,1/2]) A.SVD()

<result> ( [-0.707106781187 0.707106781187] [ 0.707106781187 0.707106781187],

[ 1.0 0.0] [ 0.0 7.85046229342e-17],

[-0.707106781187 0.707106781187] [ 0.707106781187 0.707106781187] )

The exact solution is -1/sqrt(2),1/sqrt(2), 1/sqrt(2), 1/sqrt(2)

and D=(1, 0),(0, 0)

Something like this...

Is there a way to get the exact solution?

One more question... Why doesn't the next code work?

A=matrix(RR,2,2,[1/2,-1/2,-1/2,1/2]) A.SVD()