Expectation Maximization opencv-Log Likelihood value - c++

I'm estimating the parameters of a GMM using EM,
When I use my Matlab script And run the EM code i get a single value of "log-likelihood"..
However in opencv the output of EM.train gives a matrix which contained the loglikelihood value of every sample.
How do I get a single log likelihood value? Do I need to take the minimum of all the loglikelihood values of all samples or the sum of all loglikelihood values?

You need sum of log probabilities of datapoints which you use to estimate probability density function. You'll get loglikelihood of your estimation.
You can find good explanation in "Pattern Recognition and Machine Learning" book

Related

Hyper parameter tuning for Random cut forest

I have used to below hyper parameters to train the model.
rcf.set_hyperparameters(
num_samples_per_tree=200,
num_trees=250,
feature_dim=1,
eval_metrics =["accuracy", "precision_recall_fscore"])
is there any best way to choose the num_samples_per_tree and num_trees parameters.
what are the best numbers for both num_samples_per_tree and num_trees.
There are natural interpretations for these two hyper-parameters that can help you determine good starting approximations for HPO:
num_samples_per_tree -- the reciprocal of this value approximates the density of anomalies in your data set/stream. For example, if you set this to 200 then the assumption is that approximately 0.5% of the data is anomalous. Try exploring your dataset to make an educated estimate.
num_trees -- the more trees in your RCF model the less noise in scores. That is, if more trees are reporting that the input inference point is an anomaly then the point is much more likely to be an anomaly than if few trees suggest so.
The total number of points sampled from the input dataset is equal to num_samples_per_tree * num_trees. You should make sure that the input training set is at least this size.
(Disclosure - I helped create SageMaker Random Cut Forest)

What is the max possible value of magnitude in polar system in OpenCV?

In OpenCV I'm using cartToPolar function and I want to know the max possible value of calculated magnitude. Can it be greater than 255? I found something about calculation in the documentation about Hough Line Transform, but I still do not know the max value. I need this to calculate histograms, to devide the ranges for right buckets.
Best regards,

estimate linear combination of regression coefficients in sas

I'm using a LMM in SAS and, I would like to get an estimation (and a p-value) of a linear combination of some of the regression coefficients.
Say that the model is:
b0+b1Time+b2X1+b3X2+b4(Time*X1)
and say that, I want to get an estimate and a p-value for the b1+b4.
What should I do?

Compute frequency of sinusoidal signal, c++

i have a sinusoidal-like shaped signal,and i would like to compute the frequency.
I tried to implement something but looks very difficult, any idea?
So far i have a vector with timestep and value, how can i get the frequency from this?
thank you
If the input signal is a perfect sinusoid, you can calculate the frequency using the time between positive 0 crossings. Find 2 consecutive instances where the signal goes from negative to positive and measure the time between, then invert this number to convert from period to frequency. Note this is only as accurate as your sample interval and it does not account for any potential aliasing.
You could try auto correlating the signal. An auto correlation can be rapidly calculated by following these steps:
Perform FFT of the audio.
Multiply each complex value with its complex conjugate.
Perform the inverse FFT of the audio.
The left most peak will always be the highest (as the signal always correlates best with itself). The second highest peak, however, can be used to calculate the sinusoid's frequency.
For example if the second peak occurs at an offset (lag) of 50 points and the sample rate is 16kHz and the window is 1 second then the end frequency is 16000 / 50 or 320Hz. You can even use interpolation to get a more accurate estimation of the peak position and thus a more accurate sinusoid frequency. This method is quite intense but is very good for estimating the frequency after significant amounts of noise have been added!

Measure entropy of a binary matrix

I`ve a 100*100 binary matrix the probability of each pixel given by this relation :
i want to know how to calculate the entropy of this image .
According to the given conditions, the probability for each entry in the matrix can be calculated accordingly.
For example, because s(1,1)=0, s(1,2)=0, s(2,1)=0, then you can calculate P(s(2,2)=0), and P(s(2,2)=1) using the theorem.
After you calculate all the probability for all entries, then you can start to calculate the entropy of this image by calculating the expected value.
Entropy is given by the formula: -Sum(PlogP)
Where log is the base 2 logarithm and P is the probability of the information.