5
使用Mathematica,我需要優化是在BinCounts
來定義一個函數; 我想要最大化的參數定義了bin分割點。優化使用Mathematica:使用BinCounts目標函數
我認爲這個問題是數學擴展目標函數 在參數方面被賦予數值 值之前他們,所以BinCounts
抱怨垃圾桶規格不包含真正的價值,無限「一個 列表, -無窮」。
我認爲下面是那種東西的小例子,我 試圖做的和正在發生的事情。我非常感謝關於 如何解決這個問題的建議。
In[1]:= data = RandomReal[1, 30]; (* Make some test data. *)
In[2]:= f[a_, b_, c_] := BinCounts[data, {{0, a, b, c, 1}}] (* Shorthand to use below… *)
In[12]:= g[a_, b_, c_] := Max[f[a, b, c]] - Min[f[a, b, c]] (* Objective function. *)
In[13]:= NMaximize[{g[a, b, c], 0 < a < b < c < 1}, {a, b, c}] (* Try to oprimize. *)
During evaluation of In[13]:= BinCounts::cvals: The bin specification {{0,a,b,c,1}} is not a list containing real values, Infinity, and -Infinity. >>
During evaluation of In[13]:= BinCounts::cvals: The bin specification {{0,a,b,c,1}} is not a list containing real values, Infinity, and -Infinity. >>
During evaluation of In[13]:= BinCounts::cvals: The bin specification {{0,a,b,c,1}} is not a list containing real values, Infinity, and -Infinity. >>
During evaluation of In[13]:= General::stop: Further output of BinCounts::cvals will be suppressed during this calculation. >>
Out[13]= {0., {a -> 0., b -> 0., c -> 1.}}