p2: calculate impulse func estimate

* add visualisation code
* add pic
This commit is contained in:
leo 2023-02-26 21:20:40 +01:00
parent c3070cd2c0
commit c3f9185077
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ
5 changed files with 50 additions and 1 deletions

@ -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"

26
p2/data/impulse_func.csv Normal file

@ -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
1 0.0184539137157985894122091963254206348210573196411132812500000000
2 0.0473523910649251283944138890547037590295076370239257812500000000
3 0.0439798428385898415582389020528353285044431686401367187500000000
4 0.0370162153890833331426613028725114418193697929382324218750000000
5 0.0268203707478212004244877419978365651331841945648193359375000000
6 0.0293922808417747399856168044607329647988080978393554687500000000
7 0.0287505536202991573979659278847975656390190124511718750000000000
8 0.0251912419712964144591360593494755448773503303527832031250000000
9 0.0313842198158401086693913839553715661168098449707031250000000000
10 0.0288515259300295735800379048896502354182302951812744140625000000
11 0.0319007668772124386435962151153944432735443115234375000000000000
12 0.0306864411068723079434317213554095360450446605682373046875000000
13 0.0242963375206136783512889110170362982898950576782226562500000000
14 0.0194871671066619012169240932053071446716785430908203125000000000
15 0.0125898199468795837785428659572062315419316291809082031250000000
16 0.0215156962986396832482327567959146108478307723999023437500000000
17 0.0186423123910237388545230174941025325097143650054931640625000000
18 0.0213207501556608898518607730920848553068935871124267578125000000
19 0.0263843382153661834554903009575355099514126777648925781250000000
20 0.0308940041687151834004509964870521798729896545410156250000000000
21 0.0420472567660505752717980954002996440976858139038085937500000000
22 0.0546400556881618607030226542065065586939454078674316406250000000
23 0.0617199329194972612366854036736185662448406219482421875000000000
24 0.0421812613093787772133858027245878474786877632141113281250000000
25 0.0392001223855573538434882152614591177552938461303710937500000000
26 0.0607583542008108823395673425693530589342117309570312500000000000

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

@ -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

@ -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()