diff --git a/p2/data.go b/p2/data.go index d211f1d..4d88633 100644 --- a/p2/data.go +++ b/p2/data.go @@ -85,7 +85,8 @@ func saveStuff( varianceU, varianceY, cov float64, autocorrelationU, autocorrelationY, - mutCorrelationUY, mutCorrelationYU []float64, + mutCorrelationUY, mutCorrelationYU, + impulseFunc []float64, ) error { fFnames := map[string]float64{ "mean_u": meanU, @@ -99,6 +100,7 @@ func saveStuff( "autocorrelation_y": autocorrelationY, "mutual_correlation_uy": mutCorrelationUY, "mutual_correlation_yu": mutCorrelationYU, + "impulse_func": impulseFunc, } prefix := "data/" suffix := ".txt" diff --git a/p2/data/impulse_func.csv b/p2/data/impulse_func.csv new file mode 100644 index 0000000..ec5dc54 --- /dev/null +++ b/p2/data/impulse_func.csv @@ -0,0 +1,26 @@ +0.0184539137157985894122091963254206348210573196411132812500000000 +0.0473523910649251283944138890547037590295076370239257812500000000 +0.0439798428385898415582389020528353285044431686401367187500000000 +0.0370162153890833331426613028725114418193697929382324218750000000 +0.0268203707478212004244877419978365651331841945648193359375000000 +0.0293922808417747399856168044607329647988080978393554687500000000 +0.0287505536202991573979659278847975656390190124511718750000000000 +0.0251912419712964144591360593494755448773503303527832031250000000 +0.0313842198158401086693913839553715661168098449707031250000000000 +0.0288515259300295735800379048896502354182302951812744140625000000 +0.0319007668772124386435962151153944432735443115234375000000000000 +0.0306864411068723079434317213554095360450446605682373046875000000 +0.0242963375206136783512889110170362982898950576782226562500000000 +0.0194871671066619012169240932053071446716785430908203125000000000 +0.0125898199468795837785428659572062315419316291809082031250000000 +0.0215156962986396832482327567959146108478307723999023437500000000 +0.0186423123910237388545230174941025325097143650054931640625000000 +0.0213207501556608898518607730920848553068935871124267578125000000 +0.0263843382153661834554903009575355099514126777648925781250000000 +0.0308940041687151834004509964870521798729896545410156250000000000 +0.0420472567660505752717980954002996440976858139038085937500000000 +0.0546400556881618607030226542065065586939454078674316406250000000 +0.0617199329194972612366854036736185662448406219482421875000000000 +0.0421812613093787772133858027245878474786877632141113281250000000 +0.0392001223855573538434882152614591177552938461303710937500000000 +0.0607583542008108823395673425693530589342117309570312500000000000 diff --git a/p2/res/impulse_func_estimate.png b/p2/res/impulse_func_estimate.png new file mode 100644 index 0000000..9a9d26f Binary files /dev/null and b/p2/res/impulse_func_estimate.png differ diff --git a/p2/run.go b/p2/run.go index 321675f..0390ba1 100644 --- a/p2/run.go +++ b/p2/run.go @@ -42,6 +42,11 @@ func run() error { cov := stats.Covariance(data[u], data[y]) + impulseFunc, err := stats.ImpulseFunction(autocorrelationU, mutCorrelationUY) + if err != nil { + return err + } + log.Printf("len(data): %d", len(data[u])) log.Printf("means - u: %v, y: %v", meanU, meanY) @@ -55,12 +60,16 @@ func run() error { log.Printf("mutual correlation Y,U: %v", mutCorrelationYU) log.Printf("covariance U,Y: %v", cov) + log.Printf("len(impulseFunc): %d", len(impulseFunc)) + log.Printf("impulseFunc: %v", impulseFunc) + err = saveStuff( meanU, meanY, varianceU, varianceY, cov, autocorrelationU, autocorrelationY, mutCorrelationUY, mutCorrelationYU, + impulseFunc, ) if err != nil { return err diff --git a/p2/visualise.py b/p2/visualise.py index f2b751f..f9348b3 100644 --- a/p2/visualise.py +++ b/p2/visualise.py @@ -41,3 +41,15 @@ fig = lp.get_figure() fig.subplots_adjust(top=.97) fig.savefig('res/signal_y.png') plt.clf() + +imf=pd.read_csv('data/impulse_func.csv') +lp = sb.lineplot(data=imf, legend=False, linewidth=2.5) +lp.set( + title='Impulse Function Estimate', + xlabel='time (s)', + ylabel='y', + ) +fig = lp.get_figure() +fig.subplots_adjust(top=.97) +fig.savefig('res/impulse_func_estimate.png') +plt.clf()