Skip to content

Commit

Permalink
Added Polinom
Browse files Browse the repository at this point in the history
  • Loading branch information
dormaayan committed Dec 17, 2016
1 parent 5bf0e1b commit 7a54b16
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 47 deletions.
1 change: 1 addition & 0 deletions CheckPhiDependency1.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
B = 2048;
omega = rand * 10 + epsilon;
floor_omega = ceil(omega);
phi = rand*2*pi;
[b_org,N_org,] = func1Numerically(omega,phi,A,B);
[b_org_floor,N_org_floor,] = func1Numerically(floor_omega,phi,A,B);
for j=1:1:10,
Expand Down
18 changes: 0 additions & 18 deletions CheckPhiDependency1.m~

This file was deleted.

28 changes: 0 additions & 28 deletions CheckPhiDependency3.m~

This file was deleted.

27 changes: 27 additions & 0 deletions Polinom.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
% Check our mathematical part with simple and intresting polinom
function [] = Polinom(bitBudget)
t = 0:0.00001:1;
s = (1/16)*(231*t.^6-315*t.^4+105*t.^2-5);
[bNumerical,NNumerical] = polinomNumerically(bitBudget);
qss = sampleAndQuantize(s,bitBudget,1);
mse = mseProject(s,qss);
min_b = 1;
for b=2:1:16,
tempQss = sampleAndQuantize(s,floor(bitBudget/b),b);
tempMse = mseProject(s,tempQss);
if tempMse<mse,
qss = tempQss;
mse = tempMse;
min_b = b;
end
end
qss = decompress_1d(qss,numel(t));
figure;
plot(t,s);
figure;
plot(t,qss);
fprintf('Exhausted Serch Optimal b : %d \n',min_b);
fprintf('Exhausted Serch Optimal N : %d \n',floor(bitBudget/min_b));
fprintf('Numerical Optimal b : %d \n',bNumerical);
fprintf('Numerical Optimal N : %d \n',NNumerical);
end
26 changes: 26 additions & 0 deletions Polinom.m~
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function [ s ] = Polinom(bitBudget)
t = 0:0.00001:1;
s = (1/16)*(231*t.^6-315*t.^4+105*t.^2-5);
[bNumerical,NNumerical] = polinomNumerically(bitBudget);
qss = sampleAndQuantize(s,bitBudget,1);
mse = mseProject(s,qss);
min_b = 1;
for b=2:1:16,
tempQss = sampleAndQuantize(s,floor(bitBudget/b),b);
tempMse = mseProject(s,tempQss);
if tempMse<mse,
qss = tempQss;
mse = tempMse;
min_b = b;
end
end
qss = decompress_1d(qss,numel(t));
figure;
plot(t,s);
figure;
plot(handles.axes2,t_grid,qss);
fprintf('Exhausted Serch Optimal b : %d \n',min_b);
fprintf('Exhausted Serch Optimal N : %d \n',floor(bitBudget/min_b));
fprintf('Numerical Optimal b : %d \n',bNumerical);
fprintf('Numerical Optimal N : %d \n',NNumerical);
end
2 changes: 1 addition & 1 deletion func5Numerically.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
syms symb;
fun = @(t) (2.*pi.*(beta.*t+A).*(omega+2.*alpha.*t).*cos(2.*pi.*t.*(omega+alpha.*t)+phi)+beta.*sin(2.*pi.*t.*(omega+alpha.*t)+phi)).^2;
Energy = integral(fun,0,1);
range = 2*beta*(beta+A);
range = 2*(beta+A);
b = double(solve(Energy/(6*B^2)*symb-log(2)*range^2/(6*2^(2*symb)),symb));
N = B/b;
mse = Energy/(12*N^2)+range^2/(12*2^(2*b));
Expand Down
Binary file modified gui.fig
Binary file not shown.
7 changes: 7 additions & 0 deletions polinomNumerically.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
% Numerical calculation of N,b and the mse of function 1
function [b,N] = polinomNumerically(B)
syms symb;
b = double(solve(((symb/(6*B^2))*21-log(2)/6*(4/(2^(2*symb)))),symb));
N = B/b;
end

8 changes: 8 additions & 0 deletions polinomNumerically.m~
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
% Numerical calculation of N,b and the mse of function 1
function [b,N] = polinomNumerically(B)
syms symb;
double(solve(Energy/(6*B^2)*symb-log(2)*range^2/(6*2^(2*symb)),symb));
b = double(solve(symb/(6*B^2)*21-ln?(2)/6*(4/(2^(2*symb))),symb));
N = B/b;
end

0 comments on commit 7a54b16

Please sign in to comment.