sheunsky
(Oluseun Sanuade)
February 21, 2019, 10:00pm
1
Dear All,
I am a beginner in mathematica. Please, I want to write a mathematica code to calculate seismic-to-noise ratio using the equation:
a is the amplitude scaling factor, s is the waveform and n is the noise. I have attempted to write the code as follows:
SNR = 10*Log*(Norm[s[[i]]^2, 2]/Norm[n[[i]]^2, 2], {i, nx})
I will also like to write a code to calculate peak signal to noise ratio using the equation
Pi is the peak value of s in the first equation and sigma is the variance.
SNRi.docx (11.4 KB)
I’ll try the 2nd eq. only. I assume you want each PSNR[i] calculated and accessible as array.
Do[PSNR[i] := 10 Log[(a[[i]]^2 P[[i]]^2/s^2), 10], {i, 100}]
Usually we do it like this (a List[]):
Table[10 Log[(a[[i]]^2 P[[i]]^2/s^2), 10], {i, 100}]
You could Enter as an input:
10 Log[(a[[i]]^2 P[[i]]^2/s^2), 10]
and Mathematic will have a button appear below it saying “Plot”, if you just want to see the plot
I view .nb but i do not view .docx as i don’t know what might happen if i open them and they are encrypted. Please share .nb
sheunsky
(Oluseun Sanuade)
February 22, 2019, 10:49am
3
Thank you John for your response. I want the P in the second equation to be reading the maximum value of s in the first equation.
It makes no sense to say P[[i]] if P is the max of s. Perhaps you mean Max[s[[i]]].
P=Max[Table[s[[i]],{i,100}]]; (*no?*)
SNR:=10 Log[a[[i]]^2 Norm[s[[i]]^2, 2]/Norm[n[[i]]^2, 2],10];
P:=Max[s[[i]]];
PSNR:=10 Log[(a[[i]]^2 P[[i]]^2)/sigma^2, 10];
{SNR[[1]],PSNR[[1]]}
i cannot comment on “sigma” seismic-to-noise ratio variance without seeing the material your reading. there would be endless reasonings from which to make such a thing.
sheunsky
(Oluseun Sanuade)
February 22, 2019, 5:35pm
6
Thank you John for your help. Please find attached the page of the material for proper understanding of what I intend to do.
Regards
material.pdf (45.1 KB)
danl
(Daniel Lichtblau)
February 22, 2019, 10:23pm
7
It is very unclear what you are asking. Please edit to add an explicit example of input and a clear description of desired output.
sheunsky
(Oluseun Sanuade)
February 23, 2019, 5:38pm
8
Thank you Daniel. I wish to calculate SNR for i traces as given by this equation:
where ai is the amplitude scaling factor, si is the signal in the trace and ni is the noise. I expect to see arrays of SNR for i traces.
I also need a code to calculate PSNR using this equation:
where Pi is the peak value of si in the first equation and sigmal is the variance of the noise in the first equation.
I attach the material in pdf that shows what I am trying to do.
This is what I have so far:
SNR := Table[
10Log[a[[i]]^2 Norm[trs[[i]]^2, 2]/Norm[s[[i]]^2, 2], 10], {i,
Length[trs]}];
P := Max[trs[[i]]];
PSNR := 10*Log[(a[[i]]^2 P[[i]]^2)/s^2, 10], {i, Length[trs]};
{SNR[1 ], PSNR[1 ]}
material.pdf (45.1 KB)