MrMarc

3158 Reputation

18 Badges

16 years, 269 days

MaplePrimes Activity


These are answers submitted by MrMarc

I have not been using maple for at least 2 years because I dont enjoy using my big and heavy laptop. I been mostly using my ipad. However, the citation managers for the ipad where no good so it forced me to buy a Microsoft Surface Pro 4 because I wanted a full version of word 2016.

After I bought it I checked if it could run Maple. The version I bought has a 900-MHz Intel Core m3-6Y30 processor with 4 GB RAM and 128 GB storage. If you check this link

http://www.maplesoft.com/products/system_requirements.aspx

Is says that maple need:

Windows® (32-bit)

Version CPU* Recommended RAM Hard Disk
Windows 7  1 gigahertz (GHz) or faster 32-bit (x86)

4 GB

4 GB

Windows 8.1 1 gigahertz (GHz) or faster 32-bit (x86) with support for PAE, NX, and SSE2

4 GB

4 GB

Windows 10 1 gigahertz (GHz) or faster 32-bit (x86)

 

Since my tablet only has 900-MHz I am hoping it will work! I will let you know if it works or not :-)

StandardError(Variance, R);

???

I solved the problem by using:

z := X(P());
SetProperty("DataTable0",update);

however I think it is strange that it did not work with:

z := X(P());
Do(%DataTable0 = z);

when i had a problem displaying a large matrix in Maple acer suggested that I use an embeded component. I have not tried it in your cases but it might work...

I got some more clues:

Split the game into four different scenarios:

1. A<x and B<y
2. A<x and B>=y
3. A>=x and B<y
4. A>=x and B>=y

For every possibility compute the probability p_i of it happening and the probability q_i of A winning in this scenario. The answer if the sum over i of p_i*q_i

How to do this is in Maple?

here is a simple way:

restart:
with(Statistics):

# Simulated random data with mean =0
R := Sample(RandomVariable(Normal(0, 1)), 100):

# 95% of the area under a normal curve lies within roughly 1.96 standard deviations of the mean
threshold := ExpectedValue(R)+1.96*StandardDeviation(R);

# put your empirical data here
Empiricaldata := Sample(RandomVariable(Normal(2, 1)), 100):
ex := ExpectedValue(Empiricaldata);

# Significant testing
Significant = is(ex > threshold);

                   1.807
                   1.936
                   Significant = true

I have stoped using maples QPSolve because it has poor performance.
Try formulate your problem as a least-square problem (esentially a quadratic problem)
and solve it by using LSSolve in maple.

@Alejandro Jakubi thank you for that.

Man it is hard finding infomation some time! It is like looking for a neddle in a haystack.
alec had some interesting code:

system("taskkill /im maple* /f /t");

It certainly kills maple :-) I never thought I would get so much pleasure saying that.
I will try to play around with that command and see if I can get it to save the worksheet
as well...

I havnt decided if I should upgrade or not. I am sitting on Maple 13 so maybe yes.
Pseudomodo pointed out that there are already
marketing material for maple 16 out.

http://www.adeptscience.co.uk/lp/maple16upgrade.html#?w=550

The features that exite me the most are:

i) Snippets Palettes
ii) Clickable Math™ 3.0

However, I am still missing

i) A meny item called "maplet" where you can bookmark your custom maplets.
ii) A DataTable component where you can select data directly from csv, xls, or txt file

Hopefully that will be available in future relases.

Sounds interesting.
Also look at the law of comparative advantage which I guess is the opposite of your model.

"In economics, the law of comparative advantage says that two countries (or other kinds of parties, such as individuals or firms thereas) will both gain from trade if, in the absence of trade, they have different relative costs for producing the same goods. Even if one country is more efficient in the production of all goods (absolute advantage) than the other, both countries will still gain by trading with each other, as long as they have different relative efficiencies."

Maple does not give me hives when I use it (Mathematica does)
However, Maple does give me headaches from time to time.

Seriously, I would say Maples advantage is clear and
consistent programming notation which is easy to learn.
Mathematicas notation does take time to learn.

Ok, this is what I got so far. The first constraint is working (I think)
Constraint number 2 and 3 on the otherhand is not working.

The second constraint gives an error message: cannot store ur in a floating-point r-table
The third constraint needs to be broken down in to many separate constrains I think

restart:
randomize():
with(Optimization):
with(Statistics):
with(LinearAlgebra):

N := 12:
R := RandomMatrix(N, outputoptions = [datatype = float[8]]):
ER := Vector[column]([seq(ExpectedValue(Column(R, j)), j = 1 .. N)]):

x := Vector(N+2, proc (i) options operator, arrow; `if`(i = 1, dr, `if`(i = 2, ur, w[i])) end proc):
c := Vector(N+2, proc (i) options operator, arrow; `if`(i = 1 or i = 2, 1.0, 0.) end proc):

# 1) I think this constraint is ok
Av := Matrix([[0, 0, seq(1, i = 1 .. N)]], datatype = float[8]):
bv := Vector([1], datatype = float[8]):
Av.x<bv;

# 2) This constraint most likely not ok since I get an error message;
# can not store ur in a floating-point r-table
Az := Transpose(`<,>`(Matrix([0]), Matrix([0]), ER)):
bz := Vector([ur]):
Az.x<bz;

# 3) This constraint is wrong as well. It becomes very difficult if you need to separate
# it into many different constraints ie [ Aq[1],bq,Aq[2],bq,.....Aq[N+2,bq ]
Aq := `<|>`(Vector([seq(0, i = 1 .. N+2)]), Vector([seq(0, i = 1 .. N+2)]), `<,>`(Matrix([seq(0, i = 1 .. N)]), Matrix([seq(0, i = 1 .. N)]), R)):
bq := Vector([0, 0, seq(dr, i = 1 .. 12)]):
Aq.x < bq ;

I correct myself; the sum is not constant on the 0.05 prob quantile but
the optimal point is symmetrical ie y1=y2. See below.


The problem now however is that the below code does not work when you
change the cross correlation rho which is a big letdown. :-(

How can I solve that?

restart:
with(Optimization):
with(Statistics):
with(plottools):
with(plots):

rho := 0: mu[x] := 0: mu[y] := 0: sigma[x] := 1: sigma[y] := 1:
pdf := exp(-((x-mu[x])^2/sigma[x]^2-2*rho*(x-mu[x])*(y-mu[y])/(sigma[x]*sigma[y])+(y-mu[y])^2/sigma[y]^2)/(2*(1-rho^2)))/(2*Pi*sigma[x]*sigma[y]*sqrt(1-rho^2)):
cdf := int(int(pdf, x = -infinity .. xx), y = -infinity .. yy):

quant := solve(cdf = 0.5e-1, yy):
sol := Optimization[Minimize](xx+yy, {yy = quant});

q1 := polygon([[-10, rhs(sol[2][2]), .5], [10, rhs(sol[2][2]), .5], [10, rhs(sol[2][2]), 0], [-10, rhs(sol[2][2]), 0]], color = grey):
q2 := polygon([[rhs(sol[2][1]), 10, 0], [rhs(sol[2][1]), -10, 0], [rhs(sol[2][1]), -10, .5], [rhs(sol[2][1]), 10, .5]], color = grey):
q3 := plot3d(cdf, xx = -10 .. 10, yy = -10 .. 10, axes = boxed, style = patchcontour, contours = [0.5e-1], orientation = [-90, 0]):
display({q1, q2, q3});



well y1+y2 seems to be minimized when  [y1=-1, y2=-0.48] hence
the sum is not constant on the 0.05 prob quantile and the optimal
point is not symmetrical ie y1=y2.

Does there exist some more easier way to solve for optimal y1, y2 ?? 


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

rho := 0:
mu[x] := 0:
mu[y] := 0:
sigma[x] := 1:
sigma[y] := 1:

pdf := exp(-((x-mu[x])^2/sigma[x]^2-2*rho*(x-mu[x])*(y-mu[y])/(sigma[x]*sigma[y])+(y-mu[y])^2/sigma[y]^2)/(2*(1-rho^2)))/(2*Pi*sigma[x]*sigma[y]*sqrt(1-rho^2)):

cdf := int(int(pdf, x = -infinity .. xx), y = -infinity .. yy):
sol := solve(cdf = 0.5e-1, yy):
evalf([seq([xxx, eval(sol, xx = xxx), xxx+eval(sol, xx = xxx)], xxx = -1 .. 2)], 6);

plot3d(cdf, xx = -10 .. 10, yy = -10 .. 10, axes = boxed, style = patchcontour, contours = [0.5e-1], orientation = [-90, 0]);



@Axel Vogt have a look at this. I have ploted the contour for the 0.05 probability Quantile
for a Bivariate normal distribution. There does indeed exist an optimal point which is
approx [-1,-1] that is the pint I want Maple to give me directly. I should be able to find
such point with Lagrange method.

restart:
with(Statistics):
with(LinearAlgebra):
with(plots):
N := 2:
X := Vector(N, symbol = x):
M := Vector(N, symbol = mu):
S := Vector(N, w):
CorrMat := Matrix([[1, rho], [rho, 1]]):
CoVar := Matrix([[sigma[1]^2, sigma[1]*sigma[2]*rho], [sigma[1]*sigma[2]*rho, sigma[1]^2]]):

bipdf := simplify(exp(-(1/2)*(Transpose(X-M).(1/CoVar).(X-M)))/((2*Pi)^((1/2)*N)*sqrt(Determinant(CoVar))), symbolic):
bicdf := `assuming`([int(int(bipdf, x[2] = -infinity .. y[2]), x[1] = -infinity .. y[1])], [-1 < rho and rho < 1, sigma[1] > 0, sigma[2] > 0]):
numres1 := evalf(eval(bicdf, [sigma[1] = 1, sigma[2] = 1, mu[1] = 0, mu[2] = 0, rho = 0])):

plot3d(numres1, y[1] = -4 .. 4, y[2] = -4 .. 4, axes = Boxed, title = ["0.05 Prob Quantile for Bivariate CDF", font = [TIMES, BOLD, 12]], style = patchcontour, contours = [0.5e-1]);
p1 := contourplot(numres1, y[1] = -4 .. 4, y[2] = -4 .. 4, axes = Boxed, title = ["0.05 Prob Quantile for Bivariate CDF", font = [TIMES, BOLD, 12]], contours = [0.5e-1], view = [-4 .. 4, -4 .. 4]):
p2 := plot(-1.6-y[1], y[1] = -4 .. 4, view = [-1 .. 2, -1 .. 2], color = black):
display({p1, p2});

1 2 3 4 5 6 7 Last Page 1 of 24