## 3123 Reputation

12 years, 314 days

## odd thing...

The odd thing is that:

ImportMatrix("C:\\mydir\\data1.csv");

works even though you get all the data in one column which is not optimal while

ImportMatrix("C:\\mydir\\data1.csv", source = csv);

does not work:

Error, (in ImportMatrix) no delimiter found after line 3082, column 2

## strange...

I get the following error message:

Error, (in ImportMatrix) no delimiter found after line 3082, column 2

and that is the end of the worksheet! lol

data1.xlsx

## cloud...

@Carl Love I downloaded the file from the cloud and saved it on my harddrive:

Testa_NYA.xlsx

I have also uploaded data1.xlsx (MaplePrimes wont let me upload a csv file so I converted it to a xlsx file)

data1.xlsx

However, I looked into the file and it is just a bunch of jiberish!

## Great Work!...

Great Work! I wish someone could do the same for finance :-)

## thanx...

@Carl Love that worked excellent! Saved me many many hours thanx :-)

## hummm...

@Markiyan Hirnyk

I only get error too. Something is broken on MaplePrimes...

## strange...

@Markiyan Hirnyk I try one more time. Thanx for your time and sorry for that.
Very strange it must be mapleprimes hummm

LL_101)_Quandl_Get_D.mw

## no problem...

@Markiyan Hirnyk no problem!

It turns out that the problem is more complicated than I first thought:

The original data is expressed as (for example):

GOOG/NASDAQ_A
GOOG/NASDAQ_AAS
........

1) First we need to convert it to: ( subs . for / )

GOOG.NASDAQ_A
GOOG.NASDAQ_AAS
........

2) Then we need to insert .4 ( this is the step that you helped me with ie 4th column) so we get:

GOOG.NASDAQ_A.4
GOOG.NASDAQ_AAS.4
........

3) Then we need to put everything together so we get:

http://quandl.com/api/v1/multisets.csv?columns=GOOG.NASDAQ_A.4,GOOG.NASDAQ_AAS.4

4) Then we can make the api call and get the data.

This example I just did is only for two stocks. In reality I have thousands of stocks
so we need some stable code ie copy past wont work.

## excellent...

@Markiyan Hirnyk excellent stuff!

How would you do the second step from:

GOOG.NASDAQ_GOOG.4
GOOG.NASDAQ_AAPL.4
GOOG.NASDAQ_ZN.4
GOOG.NASDAQ_ZOOM.4
....

for example to:

GOOG.NASDAQ_GOOG.4,GOOG.NASDAQ_AAPL.4,GOOG.NASDAQ_ZN.4,GOOG.NASDAQ_ZOOM.4 etc

??

## I assume it is like this then:For every ...

I assume it is like this then:

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

1. A<x and B<y          x                 y      ->    x*y
2. A<x and B>=y        x           1 -  y       ->    x*(1-y)
3. A>=x and B<y       1 - x             y       ->    (1-x)*y
4. A>=x and B>=y     1 - x       1 -  y       ->    (1-x)*(1-y)

CDF(RandomVariable(Uniform(0, 1)), .5);
CDF(RandomVariable(Uniform(0, 1)), .8);
CDF(RandomVariable(Uniform(0, 1)), .2);

0.5
0.8
0.2

z := simplify(.5*x*y+(.5-.5*y)*x*(1-y)+(.5*x+.5)*(1-x)*y+(.5+(-1+y)/(x-1))*(1-x)*(1-y), symbolic);

plot3d(z, x = 0 .. 1, y = 0 .. 1);

## I assume it is like this then:For every ...

I assume it is like this then:

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

1. A<x and B<y          x                 y      ->    x*y
2. A<x and B>=y        x           1 -  y       ->    x*(1-y)
3. A>=x and B<y       1 - x             y       ->    (1-x)*y
4. A>=x and B>=y     1 - x       1 -  y       ->    (1-x)*(1-y)

CDF(RandomVariable(Uniform(0, 1)), .5);
CDF(RandomVariable(Uniform(0, 1)), .8);
CDF(RandomVariable(Uniform(0, 1)), .2);

0.5
0.8
0.2

z := simplify(.5*x*y+(.5-.5*y)*x*(1-y)+(.5*x+.5)*(1-x)*y+(.5+(-1+y)/(x-1))*(1-x)*(1-y), symbolic);

plot3d(z, x = 0 .. 1, y = 0 .. 1);

## Thanxs Chris :-)    I hav...

Thanxs Chris :-)    I have some more clues for you;

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

1. when A<x and B<y: both A and B get another random number so p = 0.5
2. when A<x and B>=y: A gets another number while B stays. So the probability of A winning is 1-b when b is B's number which is >=y. So to compute that evaluate the average (which is the integral from y to 1 of 1-B divided by 1-y) which is (1/2-y+y^2/2)/(1-y).
3. when A>=x and B<y: A stays and B gets a random number.   So the probability of A winning is a when a is A's number which is >=x. So to compute that evaluate the average (which is the integral from x to 1 of A divided by 1-x) which is (1/2-x^2/2)/(1-x).
4. when A>=x and B>=y: both stay. If x<y then the probability of A winning is the integral of (1-B)/(1-x) when B goes from y to 1, divided by (1-y) which is (1/2-y+y^2/2)/((1-x)(1-y))

So the probability of A winning for the last three scenarious (the first one is given P(A win)=0.5) are:

simplify(eval(int((1-B)/(1-y), B = y .. 1)), symbolic);
simplify((1/2-y+(1/2)*y^2)/(1-y), symbolic);

simplify(eval(int(A/(1-x), A = x .. 1)), symbolic);
simplify((1/2-(1/2)*x^2)/(1-x), symbolic);

simplify(eval((int((1-B)/(1-x), B = y .. 1))/(1-y)), symbolic);
simplify((1/2-y+(1/2)*y^2)/((1-x)*(1-y)), symbolic);

1   1
- - - y
2   2
1   1
- - - y
2   2
1     1
- x + -
2     2
1     1
- x + -
2     2
-1 + y
---------
2 (x - 1)
-1 + y
---------
2 (x - 1)

Now I just have to figure out how to get:

"For every possibility compute the probability p_i of it happening"

and then simply sum over i of p_i*q_i.   Any ideas?

## Thanxs Chris :-)    I hav...

Thanxs Chris :-)    I have some more clues for you;

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

1. when A<x and B<y: both A and B get another random number so p = 0.5
2. when A<x and B>=y: A gets another number while B stays. So the probability of A winning is 1-b when b is B's number which is >=y. So to compute that evaluate the average (which is the integral from y to 1 of 1-B divided by 1-y) which is (1/2-y+y^2/2)/(1-y).
3. when A>=x and B<y: A stays and B gets a random number.   So the probability of A winning is a when a is A's number which is >=x. So to compute that evaluate the average (which is the integral from x to 1 of A divided by 1-x) which is (1/2-x^2/2)/(1-x).
4. when A>=x and B>=y: both stay. If x<y then the probability of A winning is the integral of (1-B)/(1-x) when B goes from y to 1, divided by (1-y) which is (1/2-y+y^2/2)/((1-x)(1-y))

So the probability of A winning for the last three scenarious (the first one is given P(A win)=0.5) are:

simplify(eval(int((1-B)/(1-y), B = y .. 1)), symbolic);
simplify((1/2-y+(1/2)*y^2)/(1-y), symbolic);

simplify(eval(int(A/(1-x), A = x .. 1)), symbolic);
simplify((1/2-(1/2)*x^2)/(1-x), symbolic);

simplify(eval((int((1-B)/(1-x), B = y .. 1))/(1-y)), symbolic);
simplify((1/2-y+(1/2)*y^2)/((1-x)*(1-y)), symbolic);

1   1
- - - y
2   2
1   1
- - - y
2   2
1     1
- x + -
2     2
1     1
- x + -
2     2
-1 + y
---------
2 (x - 1)
-1 + y
---------
2 (x - 1)

Now I just have to figure out how to get:

"For every possibility compute the probability p_i of it happening"

and then simply sum over i of p_i*q_i.   Any ideas?

 1 2 3 4 5 6 7 Last Page 2 of 33
﻿