Click here to Skip to main content
16,007,885 members
Home / Discussions / C#
   

C#

 
GeneralRe: Multiple values in a querystring Pin
ferronrsmith10-Jan-09 9:55
ferronrsmith10-Jan-09 9:55 
GeneralRe: Multiple values in a querystring Pin
sudhanvag10-Jan-09 15:59
sudhanvag10-Jan-09 15:59 
QuestionRead and copy .docx Pin
Xtrme_XJ9-Jan-09 8:23
Xtrme_XJ9-Jan-09 8:23 
Questionunisgned integers and global cases in C# Pin
Xarzu9-Jan-09 7:54
Xarzu9-Jan-09 7:54 
AnswerRe: unisgned integers and global cases in C# Pin
Eddy Vluggen9-Jan-09 8:24
professionalEddy Vluggen9-Jan-09 8:24 
AnswerRe: unisgned integers and global cases in C# Pin
JByrd20069-Jan-09 9:02
JByrd20069-Jan-09 9:02 
AnswerRe: unisgned integers and global cases in C# Pin
Guffa9-Jan-09 17:52
Guffa9-Jan-09 17:52 
Questionany body idea in viterbi algorithm Pin
lawrenceinba9-Jan-09 7:39
lawrenceinba9-Jan-09 7:39 
viterbi algorithm in c#


can any one explain wats happening in the code


i need working of this code,,, antyone pls

using System;
using System.Collections.Generic;
using System.Text;

namespace Viterbi
{
public class ForwardViterbi
{

// The Class Globals
string[] states;
string[] observations;
double[] startProbability;
double[,] transitionProbability;
double[,] emissionProbability;
double scaleFactor;

//Computed Variables
int[] vPath; //The Viterbi Path
double[] vProbs;

//----------------------------------------------------------------------
// The Getters or Accessors

public int[] VPath
{
get { return vPath; }
}

public double[] VProbs
{
get { return vProbs; }
}

//----------------------------------------------------------------------
//Constructor
public ForwardViterbi(string[] states, string[] observations, double[] startProbability, double[,] transitionProbability, double[,] emissionProbability, double scaleFactor)
{

this.states = states;
this.observations = observations;
this.startProbability = startProbability;
this.transitionProbability = transitionProbability;
this.emissionProbability = emissionProbability;
this.scaleFactor = scaleFactor;

}

//----------------------------------------------------------------------
//The Methods

public void Process(int[] problem)
{

double[,] T = new double[states.Length, 3]; //We will store the probability sequence for the Viterbi Path
vPath = new int[problem.Length];
vProbs = new double[problem.Length];

//initialize T
//------------------------------------------------------------------
for (int state = 0; state < states.Length; state++)
{
T[state, 0] = startProbability[state];
T[state, 1] = state;
T[state, 2] = startProbability[state];
}

for (int output = 0; output < problem.Length; output++)
{

double[,] U = new double[states.Length, 3]; //We will use this array to calculate the future probabilities

Console.WriteLine("\nTesting hypothesis {0} ({1})", output, observations[problem[output]]);
double highest = 0;

for (int nextState = 0; nextState < states.Length; nextState++)
{
double total = 0;
double argMax = 0;
double valMax = 0;

Console.WriteLine(" Estimating probability for future state {0} ({1})", nextState, states[nextState]);
for (int state = 0; state < states.Length; state++)
{

Console.WriteLine(" The testing state is {0} ({1})", states[state], state);
double prob = T[state, 0];
double v_path = T[state, 1];
double v_prob = T[state, 2];
double p = emissionProbability[state, problem[output]] * transitionProbability[state, nextState] * scaleFactor;
prob *= p;
v_prob *= p;
total += prob;

if (v_prob > valMax)
{
valMax = v_prob;
argMax = nextState;
}

Console.WriteLine(" VProbability of {0} is {1} with scale {2}^{3}", states[nextState], v_prob, scaleFactor, output + 1);

if (v_prob > highest)
{
highest = v_prob;
vPath[output] = nextState;
vProbs[output] = v_prob;
}
}

U[nextState, 0] = total;
U[nextState, 1] = argMax;
U[nextState, 2] = valMax;
}
T = U;
Console.WriteLine("The highest probability was {0} in state {1} (scale factor of {2}^{3})", highest, states[vPath[output]], scaleFactor, output + 1);
}


//Apply SumMax
double Total = 0;
double ValMax = 0;

for (int state = 0; state < states.Length; state++)
{
double prob = T[state, 0];
double v_path = T[state, 1];
double v_prob = T[state, 2];

Total += prob;
if (v_prob > ValMax)
{
ValMax = v_prob;
}
}

Console.WriteLine("\nAnalysis: Total probability (sum of all paths) for the given state is :: {0}\nThe Viterbi Path Probability is :: {1}", Total, ValMax);
Console.WriteLine("The above results are presented with a scale factor of {0}^{1}", scaleFactor, problem.Length);

}
}; // end Forward Viterbi Class
}
AnswerRe: any body idea in viterbi algorithm Pin
Christian Graus9-Jan-09 7:46
protectorChristian Graus9-Jan-09 7:46 
GeneralRe: any body idea in viterbi algorithm Pin
lawrenceinba9-Jan-09 8:00
lawrenceinba9-Jan-09 8:00 
AnswerRe: any body idea in viterbi algorithm Pin
EliottA9-Jan-09 8:01
EliottA9-Jan-09 8:01 
GeneralRe: any body idea in viterbi algorithm Pin
Luc Pattyn9-Jan-09 8:20
sitebuilderLuc Pattyn9-Jan-09 8:20 
GeneralRe: any body idea in viterbi algorithm Pin
Eddy Vluggen9-Jan-09 8:40
professionalEddy Vluggen9-Jan-09 8:40 
GeneralRe: any body idea in viterbi algorithm Pin
Luc Pattyn9-Jan-09 9:55
sitebuilderLuc Pattyn9-Jan-09 9:55 
GeneralRe: any body idea in viterbi algorithm Pin
Eddy Vluggen9-Jan-09 11:03
professionalEddy Vluggen9-Jan-09 11:03 
QuestionHow to export a bitmap from a crystal report? Pin
davebarkshire9-Jan-09 6:00
davebarkshire9-Jan-09 6:00 
AnswerRe: How to export a bitmap from a crystal report? Pin
DaveyM699-Jan-09 7:11
professionalDaveyM699-Jan-09 7:11 
GeneralRe: How to export a bitmap from a crystal report? Pin
c0ax_lx12-Jan-09 2:02
c0ax_lx12-Jan-09 2:02 
GeneralRe: How to export a bitmap from a crystal report? Pin
DaveyM6912-Jan-09 6:31
professionalDaveyM6912-Jan-09 6:31 
GeneralRe: How to export a bitmap from a crystal report? Pin
c0ax_lx12-Jan-09 22:17
c0ax_lx12-Jan-09 22:17 
GeneralRe: How to export a bitmap from a crystal report? Pin
DaveyM6913-Jan-09 1:13
professionalDaveyM6913-Jan-09 1:13 
GeneralRe: How to export a bitmap from a crystal report? Pin
DaveyM6913-Jan-09 1:14
professionalDaveyM6913-Jan-09 1:14 
QuestionHow to play flash Pin
Sokka939-Jan-09 5:59
Sokka939-Jan-09 5:59 
AnswerRe: How to play flash Pin
EliottA9-Jan-09 6:11
EliottA9-Jan-09 6:11 
GeneralRe: How to play flash Pin
scottgp9-Jan-09 6:27
professionalscottgp9-Jan-09 6:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.