interpolationをつかう
https://github.com/incanter/incanter/wiki/Interpolation
対象とするソフトマックス関数の定義
(defn softmax [a] (let c' (apply max a) c (repeat (length a) c') exp_a (exp (minus a c)) sum_exp_a (sum exp_a) y (div exp_a sum_exp_a)] y))
プロット
(require '[incanter.interpolation :refer :all]) (require '[incanter [charts :as charts] [core :as core]]) (defn plot [fn] (-> (charts/function-plot fn 0 11) (charts/add-points (map first points) (map second points)) (core/view))) (let [a (matrix (map #(- (* 1/10 %1) 5) (range 100))) y (softmax a)] (binding [points (into [] (map vector a y))] (plot (interpolate points :polynomial))))