MrMarc

3163 Reputation

18 Badges

17 years, 133 days

MaplePrimes Activity


These are answers submitted by MrMarc

 

ok, thanx alec I will try that :-)

 

and how do I do that ? 


Let say a have a vector A with 100 random numbers and I want to display A[1] in a MathContainer when I press the

button for the first time and when I press the button the second time I want to display A[2]  etc etc

 

I found the following. I have not done it myself so please post the code when you are done :-)

 

my goal is to find an good algorithm that can tell me what marginal distributions I should use for the Gaussian Copual to

find the best fit to some empirical data.  When I tested the MLH or method of moments with a normal copual it

suggested that a normal and a gumble marginal distribution provided the best fit when in reality the data had been generated by

2*gumbel maginal distributions and a  Normal copula. I therefore find inference difficult when it comes fitting joint distributions and

copulas to empirical data... 

 

 

 

ok, thanx for your work Alec  !   :-)     I increased your sample size to 3000 and the two solutions became more or less identical :-)

 

I also tried Roberts solution and I got the same error message as he

 

restart;
with(Statistics); with(LinearAlgebra);

F := proc (x, y) options operator, arrow; (1/2)*exp(-(1/2)*x^2-(1/2)*y^2)/Pi end proc;
C := proc (u, v) options operator, arrow; F(Quantile(Normal(0, 1), u), Quantile(Normal(0, 1), v)) end proc;

n := 300; for i to n do
x[i] := Sample(RandomVariable(Gumbel(0, 1)), 1)[1];
y[i] := Sample(RandomVariable(Gumbel(4, 2)), 1)[1];
z[i] := C(CDF(RandomVariable(Gumbel(0, 1)), x[i]), CDF(RandomVariable(Gumbel(4, 2)), y[i]))
end do;

MM := Transpose(Matrix([[seq(x[i], i = 1 .. n)], [seq(y[i], i = 1 .. n)]]))

f := C(PDF(RandomVariable(Gumbel(a, b)), x), PDF(RandomVariable(Gumbel(c, d)), y));
data := convert(MM, listlist); with(Optimization);
LL := add(eval(ln(f), {x = p[1], y = p[2]}), p = data);
NLPSolve(LL, a = 0 .. 2, b = 1 .. 2, c = 0 .. 5, d = 1 .. 4)

 

Error, (in Optimization:-NLPSolve) complex value encountered

 

ok, I think I see your point . The two Marginal Distributions are a Gumbe(a,b) distribution and a Normal(c,d) distribution.

 

restart:
with(Statistics):
with(plots):


F := proc (x, y) options operator, arrow; (1/2)*exp(-(1/2)*x^2-(1/2)*y^2)/Pi end proc : # Bivariate Normal zero means, stdev and corr


C := proc (u, v) options operator, arrow; F(Quantile(Normal(0, 1), u), Quantile(Normal(0, 1), v)) end proc : # copula function


C(PDF(RandomVariable(Gumbel(a, b)), x), PDF(RandomVariable(Normal(c, d)), y)) ;  #  PDF joint bivariate dist Gumle-Normal

 

(1/2)*exp(-RootOf(erf(_Z)*b*exp(exp((-x+a)/b))+b*exp(exp((-x+a)/b))-2*exp((-x+a)/b))^2-RootOf(erf(_Z)*sqrt(Pi)*d+sqrt(Pi)*d-sqrt(2)*exp(-(1/2)*(-y+c)^2/d^2))^2)/Pi

 

So I think we need higher moments such as skewness and kurtosis to be able to pinpoint the correct joint distribution for empirical data but I am not sure.......

ok, thanx for your input..


Do you mean that I should simply calculate the mean, variance, skewness and kurtosis for each column in the empirical data

matrix and then simulate data by using various marginal distributions for the gaussian copula and again calculate the mean,

variance, skewness and kurtosis for each marginal distribution and see where the fit is best...? Do you have any example of this?!

 

I dont know .. I am making things up as a go along, ha ha. As I said I am no expert in this

but maybe you are right maybe the two CDF should be the same ie normal (0,1) and then introduce fat tails ets trough

RandomVariable. At least I am starting to get something that looks like a distribution by using a copula generator given by

theta := 160;

C := proc (u, v) options operator, arrow; u*v+theta*u*v*(1-u)*(1-v) end proc

ok, thanx for your input Robert :-)  I will try that.. ..

Further, I have started experimenting with copula functions and I was wondering what you think about this code

Am I on the right track ?!  I have never seen it be done in Maple so it is a stab in the dark..

 

restart :
with(Statistics) :
with(LinearAlgebra) :
with(plots) :
C := proc (u, v) options operator, arrow; min(u, v) end proc :
z := proc (X, Y) options operator, arrow; C(CDF(Normal(0, 3), X), CDF(Gumbel(0, 1), Y)) end proc :

plot3d(z(X, Y), X = 0 .. 1, Y = 0 .. 1, axes = box, style = patchcontour, color = grey, contours = 20) ;  

n := 800 :

X := Transpose(Sample(RandomVariable(Normal(0, 3)), n)) :
Y := Transpose(Sample(RandomVariable(Gumbel(0, 2)), n)) :

Z := Vector([seq(z(X[i], Y[i]), i = 1 .. n)]) :

MM := Matrix([X, Y, Z]) :

pointplot3d(MM, axes = box, color = red);

I want to reproduce the below picture. If I sample random numbers from three Univariate Gumbel(0,2) distributions and then

plot the sample cordinates {x,y,z} in a 3d space with pointplot3d and then apply a contourplot to the points I should be able to

get the picture under Gumbel, or ?. maybe I am wrong here...?!   

 

 

thanx for your input herclau and your worksheets. A pivottable works great !   :-)     

The only problem is that it can be slow when the data set is large.  but other than that it is a great tool

....

 

If you go to the tool "Server Surface Area Configuration" in Microsoft Express 2005

and then select  "Surface Area Configuration for Services and Connections"  and select "Remote Connections"  you will find

the text:

 

"By default, SQL Server 2005 Express, Evaluation and Developer editions allow local client connection only.

Enterprise, standard and workgroup editions also listen for remote client connection over TCP / IP".

 

maybe I am interpreting this wrong but to me it sound like the Express edition does not support TCP / IP ?!

but I might be wrong

 

I have already done everything that your link says without any luck ...:-)

 

I think I found the solution to my problem after I have waisted one week trying to get this to work.

After have read 1000 GB of suggestions, instructions and code I found a footnote somewhere saying that:

 

Microsoft SQL Server 2005

Express, Evaluation and Developer = Only local connection

Enterprise, Standard and workgroup = Remote TCP / IP

 

ha, ha . If they only could have told me that one week ago. So much information and so much NOISE.

 

So my only option is to buy microsoft SQL Server standard edition........:-)

 

equally unsuccessful. I think the problem goes deeper... something is way wrong here.... and I would like to find out what.

I wonder if anyone has successfully connected Microsoft SQL Server to Maple 12 ?

 

thanx for your input but unfortunately that did not do the trick.... I have been struggling with this for days now. Quite annoying.... :-)

First 15 16 17 18 19 20 21 Page 17 of 24