# Question:How to compare distribution of real data and a custom distribution in this case?

## Question:How to compare distribution of real data and a custom distribution in this case?

Maple

restart;

with(ExcelTools):

with(ListTools):

with(DynamicSystems):

filename := "MSFT";

close3 := Import(cat(cat("C://US//",filename),".xls"), filename, "E2:E100");

this i usually use ln(close3[n]/close[n-1]) as the original series

as i do not know whether Sample in statistics package can use this directly,

or

need to use counting to classify them into some group and got a distribution graph

such as [1,3,5,8,6,3,1] and then turn this distribution into Distribution for Statistics package

How to convert data in close3 to Sample for Statistics package use?

p := 0.3;

q := 0.2;

MartinPoisson := (p/((p+2*q*T)/(1+p*T+q*T^2)-(p*T+q*T^2)*(p+2*q*T)/(1+p*T+q*T^2)^2))^r*r^2*T^n/factorial(n);

Dist := subs(T=t,MartinPoisson) assuming t > 0;

MartinDist := Distribution(CDF = unapply(Dist, t)) assuming t > 0; #Change 2

K := unapply(MartinDist(t-1),t);

plot(K, -1 .. 2, thickness = 3);

First error can not draw

Hermit distribution

restart;

with(Statistics):

with(plots):

Density := 2*exp(-t^2)*sqrt(Pi);

Dist := int(Density, t);

Dist := int(Density, t=-infinity..x); # Convert Density to Distribution function

Dist := subs(x=t,Dist);

CDF2 := unapply(Dist(t-1),t);

K := unapply(Dist(t-1),t);

plot(K, -1 .. 2, thickness = 3);

Second Error can not draw too

Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

# Method 1 draw graph to compare distribution

p := 0.3;

q := 0.2;

MartinPoisson := (p/((p+2*q*T)/(1+p*T+q*T^2)-(p*T+q*T^2)*(p+2*q*T)/(1+p*T+q*T^2)^2))^r*r^2*T^n/factorial(n);

Dist := subs(T=t,MartinPoisson) assuming t > 0;

X := RandomVariable(Distribution(CDF = unapply(Dist(t-1),t)));

S := Sample(X, 10^2);

R := Rank(S);

B := OrderByRank(S, R);

Y := RandomVariable(EmpiricalDistribution(B));

Y := RandomVariable(Normal(1,4));

plot([proc (t) options operator, arrow; CDF(Y, t) end proc, proc (t) options operator, arrow; CDF(X, t) end proc], color = [red, blue], thickness = 2);

i find a post http://www.mapleprimes.com/posts/119903-The-KolmogorovSmirnov-Test and do the same thing again but i do not know why to use EmpiricalDistribution

actually i have three tasks need to do

1. convert above real data into sample and then compare real data distribution with custom distribution made by myself called MartinPoisson

2. convert above real data into sample and then compare real data distribution with existing distribution in Maple such as Normal, Beta, Gamma

3. compare custom distribution with existing distribution in Maple such as Normal, Beta, Gamma

how to do these 3 tasks in Maple?

﻿