diff options
| author | ziejd2 | 2021-10-11 16:00:02 -0500 |
|---|---|---|
| committer | ziejd2 | 2021-10-11 16:00:02 -0500 |
| commit | 566a4de3fcc9b90da036dbf385044319c11a2b6a (patch) | |
| tree | 15c23be0643f41128f11cf9bb378ed505e259a6b /sourcecodes/k-best/src/ls_NML.c | |
| parent | a20784bad5cfa214ce23d16695d0064571bae9c3 (diff) | |
| parent | 73ba58868451b5fc6611e1feaa9b63f17b6cd19d (diff) | |
| download | BNW-566a4de3fcc9b90da036dbf385044319c11a2b6a.tar.gz | |
Resolved merge conflict
Diffstat (limited to 'sourcecodes/k-best/src/ls_NML.c')
| -rw-r--r-- | sourcecodes/k-best/src/ls_NML.c | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/sourcecodes/k-best/src/ls_NML.c b/sourcecodes/k-best/src/ls_NML.c deleted file mode 100644 index 6c3523a4..00000000 --- a/sourcecodes/k-best/src/ls_NML.c +++ /dev/null @@ -1,77 +0,0 @@ -#include <math.h> -#include "get_local_scores.h" -#include "ilogi.h" -#include "reg.h" -#include "ls_NML.h" - -extern int* nof_vals; -extern int N; - -#define BIG_NML_DATA (1<<16) - -/* NML = log(ML) - log(REGRET) */ - -score_t big_nml_score(int i, varset_t psi, int nof_freqs){ - - int vc_v = nof_vals[i]; - int* freqp = freqmem; - int* end_freqp = freqp + nof_freqs * vc_v; - - score_t res = 0.0; - - for(;freqp < end_freqp; freqp += vc_v) { - int pcfreq = 0; - int v; - for(v = 0; v<vc_v; ++v) { - int freq = freqp[v]; - if (freq) { - pcfreq += freq; - res += (freq < BIG_NML_DATA) ? ilogi[freq] : freq * log(freq); - } - } - res -= (pcfreq < BIG_NML_DATA) ? ilogi[pcfreq] : pcfreq * log(pcfreq); - res -= log(reg(pcfreq, vc_v)); /* regret */ - } - - return res; -} - -score_t nml_score(int i, varset_t psi, int nof_freqs){ - - int vc_v = nof_vals[i]; - int* freqp = freqmem; - int* end_freqp = freqp + nof_freqs * vc_v; - - score_t res = 0.0; - - for(;freqp < end_freqp; freqp += vc_v) { - int pcfreq = 0; - int v; - for(v = 0; v<vc_v; ++v) { - int freq = freqp[v]; - if (freq) { - pcfreq += freq; - res += ilogi[freq]; - } - } - res -= ilogi[pcfreq]; - res -= log(reg(pcfreq, vc_v)); /* regret */ - } - - return res; -} - - -scorefun init_NML_scorer(){ - if (N<BIG_NML_DATA){ - ensure_ilogi(N); - return nml_score; - } else { - ensure_ilogi(BIG_NML_DATA); - return big_nml_score; - } -} - -void free_NML_scorer(){ - free_ilogi(); -} |
