English 中文(简体)
通过简明武力算法确定正确参数
原标题:Find the right parameter through a brute force algorithm

我已实现了压缩算法,假定我放弃,要求:

myCompression(data, th)

<>th>/em>参数在0到1之间。 有时这个数字实际上可能很小,例如212.19e-013。

num = length(myCompression(data, th))

gave me the number of data remains after compression. If I want num to be bigger, I need to choose a lower th parameter. Viceversa, if I want higher num, I have to choose lower th.

Now the problem is: I want to find a proper th such that num is equal to a target number that I choose. As you know, find th is really long work, and I would realize a brute force algorithm that finds th that satisfy my need. I ve write this:

target = 304;
th = 2.49e-011;
num = 0;

while(num~=target)    
    num = length(MCSimplify3(time, latitudes, longitudes, th));
    disp(horzcat( tol:  , num2str(th),   num:  , num2str(num)));

    if (num>target)
        th = th+(rand()*th);
    else
        th = th-(rand()*th);
    end

    th = abs(th);
end

以前的文字开始,但从未达到目标。 问题Ippose是由于添加或细分的(rand()*th)过于庞大,因此时间超过了目标,时间低于一个。 因此,正如你可以在这里看到的那样,这种局面继续推移,而且永远无法取得结果:

tol: 2.67e-012 num: 333
tol: 4.0685e-012 num: 303
tol: 2.9909e-012 num: 320
tol: 3.1953e-012 num: 316
tol: 4.5895e-012 num: 298
tol: 3.7916e-012 num: 308
tol: 3.8906e-012 num: 308
tol: 7.6049e-012 num: 257
tol: 4.3302e-012 num: 299
tol: 1.6646e-013 num: 624
tol: 2.9337e-013 num: 562
tol: 2.9553e-013 num: 561
tol: 4.965e-013 num: 503
tol: 8.47e-013 num: 448
tol: 1.3934e-012 num: 391
tol: 2.163e-012 num: 350
tol: 2.6348e-012 num: 335
tol: 4.6699e-012 num: 296

谁能帮助我?

问题回答

首先,引用你向我们显示的数据图表。 这应当给你一个明确的想法,即你在什么地方直接寻找<条码>第的价值,这给你寻求的目标价值。

第二,在适当幅度内通过<代码>th的数值进行某种搜索;即使是简单两节的检索,对预期目标价值进行分类,也将比你目前的做法好。

仅凭对你的数据的观察,就<代码>304的目标价值而言,th的价值应载于 (3.7916e-012,4.0685e-012)

越是这样,越是看你目录,就越需要做的头一件事是去除<条码>兰德<>>>>。 这就是说的,我指的是Nelder-Mead

从更实际的角度来看,你应当用固定(如0.1)或可计量南到目标距离的变量,以不同的参数取代大面积。

另一种做法是,你可以采用尽量减少例行做法,例如使用Nelder-Mead,可能有一些小的拖网,用于消除连续性。

如果不能够实施法典,就很难给予更多的信息(即,我需要简化标准)。

有了高性能标志的宝贵渠道,我是如何解决的。

target = 304;
len = 0;

a = 0;
b = 1;

while(len~=target)
    c = (a+b)/2;
    len = length(MCSimplify3(time, latitudes, longitudes, c));
    if(len<target)
        b = c;
    end
    if (len>target)
        a = c;
    end
    if (len==target)
        disp(horzcat( tol:  , num2str(th),   num:  , num2str(len)));
    end
end




相关问题
MATLAB Solving equations problem

I want to solve these equations using MATLAB and I am sure there is a non zero solution. The equations are: 0.7071*x + 0.7071*z = x -0.5*x + 0.7071*y + 0.5*z = y -0.5*x - 0.7071*y +...

Difference between MATLAB s matrix notations

How do you read the following MATLAB codes? #1 K>> [p,d]=eig(A) // Not sure about the syntax. p = 0.5257 -0.8507 -0.8507 -0.5257 d = ...

preventing data from being freed when vector goes out of scope

Is there a way to transfer ownership of the data contained in a std::vector (pointed to by, say T*data) into another construct, preventing having "data" become a dangling pointer after the vector goes ...

Divide two polynomials using MATLAB

I want to divide p(x) by q(x) given that: p(x)=-5x^4+3x^2-6x q(x)=x^2+1 I tried: p=inline( -5*(x^4)+3*(x^2) , x ) p = Inline function: p(x) = -5*(x^4)+3*(x^2) q=inline( x^2+1 , x ) q = ...

matlab deals with Fibbonacci

The Fibonacci series is given as follows: 1, 2, 3, 5, 8, 13, 21, ... How can I write a script which calculates and prints the n-th Fibonacci term (for n>2), where n is inputed by the user. This ...

How do I plot lines between all points in a vector?

I have a vector containing some points in 2-D space. I want MATLAB to plot these points with lines drawn from every point to every other point. Basically, I want a graph with all vertices connected. ...

How do I create a string using a loop variable in MATLAB?

I have a loop like this: for i=1:no %some calculations fid = fopen( c:\out.txt , wt ); %write something to the file fclose(fid); end I want data to be written to different files like ...

热门标签