Finding terminal states in markov chain matrix (Simple project)

I want someone to solve this problem in either Java/python.

Write a function answer(m) that takes an array of array of nonnegative ints representing how many times that state has gone to the next state and return an array of ints for each terminal state giving the exact probabilities of each terminal state, represented as the numerator for each state, then the denominator for all of them at the end and in simplest form. The matrix is at most 10 by 10. It is guaranteed that no matter which state the elements is in, there is a path from that state to a terminal state. That is, the processing will always eventually end in a stable state. The elements starts in state 0. The denominator will fit within a signed 32-bit integer during the calculation, as long as the fraction is simplified regularly. For example, consider the matrix m:


[0,1,0,0,0,1], # s0, the initial state, goes to s1 and s5 with equal probability

[4,0,0,3,2,0], # s1 can become s0, s3, or s4, but with different probabilities

[0,0,0,0,0,0], # s2 is terminal, and unreachable (never observed in practice)

[0,0,0,0,0,0], # s3 is terminal

[0,0,0,0,0,0], # s4 is terminal

[0,0,0,0,0,0], # s5 is terminal


So, we can consider different paths to terminal states, such as:

s0 -> s1 -> s3

s0 -> s1 -> s0 -> s1 -> s0 -> s1 -> s4

s0 -> s1 -> s0 -> s5

Tracing the probabilities of each, we find that

s2 has probability 0

s3 has probability 3/14

s4 has probability 1/7

s5 has probability 9/14

Function format:


public static int[] calculate(int[][] m) {

// Your code goes here.



def answer(m):

Your program will be tested for custom inputs.

Skills: Java, Mathematics, Python

See more: draw markov states matrix, matrix chain, markov chain creator, java markov chain generate text, markov chain text, java markov chain, markov chain text database, markov chain text processing, finding sponsor work united states, php markov chain, php markov chain example, markov chain text generation, markov chain text generator online, markov chain text generator, simple project marketing research, simple project management php script, simple project timekeeping program, possible simple project, simple project management script, flash simple project, markov chain generator, simple project flash, mysql php simple project, simple project jsp servlet, database php simple project

About the Employer:
( 0 reviews ) Atlanta, United States

Project ID: #11985708

20 freelancers are bidding on average $33 for this job


I have completed my MS in Electrical Engineering and working in the field of designing for last 3 years. My projects have won more then 10 national level competitions. Area of Expertise -Discrete Time Signal Processing More

$100 USD in 1 day
(82 Reviews)

Easy project for me to finish it within a day

$20 USD in 1 day
(100 Reviews)
$45 USD in 1 day
(56 Reviews)

Feel fee to contact me [login to view URL] me message to discuss further more details .We provide the comments,images,videos,demos and live sessions in order to help the [login to view URL] payment only after the work done. You ca More

$40 USD in 1 day
(39 Reviews)
$60 USD in 1 day
(41 Reviews)
$50 USD in 1 day
(21 Reviews)

Hi, I am competitive to this kind of task, can take good care of this project. In fact, I already done related to this job before. Let me know the best of your time so we can discuss further based on your requirements More

$29 USD in 0 days
(9 Reviews)

Hello. More 20 years programming experience. I need more details to set real time and price. Regards. -------------------------------------------------------------------------------------------------------------- More

$40 USD in 2 days
(8 Reviews)
$25 USD in 1 day
(5 Reviews)

Could you provide any math paper that how to calculate probabilities? If not, i'll find them by myself. Will provide python code

$30 USD in 0 days
(2 Reviews)
$30 USD in 1 day
(4 Reviews)

Computer Science graduate and have experience in java Work on many projects of java So i will support you project as much you required. please check my profile i have done many project on java. hope will see you. More

$20 USD in 1 day
(4 Reviews)

Hello Sir, Raheel here. I've done too many projects in Java and Python having great knowledge about it. I assure you that I'll deliver your project on time and you can also visit my profile for surety. I hope you wi More

$25 USD in 1 day
(6 Reviews)
$30 USD in 1 day
(3 Reviews)

We are team of excellent developers and writers. We have 2 year experience related to your project field. We can do your project and solve your all problems according to your requirements. We have read your description More

$25 USD in 1 day
(2 Reviews)

I can write this for you. I like working with markov chains. I have revised this to 20 dollars Thank you

$25 USD in 1 day
(1 Review)

I have fair amount of experience in econometrics modeling in Python. I have implemented many macro-econometric models in python related to monetary economics and other financial data. I am comfortable in the usual pac More

$30 USD in 1 day
(3 Reviews)
$23 USD in 6 days
(1 Review)

Your program is ready Your program is ready Your program is ready The following is a test case ====================== int[][] m = new int[][]{{0, 1, 0, 0, 0, 1}, {4, 0, 0, 3, 2, 0}, {0, 0, 0, 0, More

$25 USD in 1 day
(0 Reviews)

We are the leading young professional software development organization having extensive technical expertise and knowledge in developing, managing, optimizing and customizing software’s both in Web and Desktop Applicat More

$25 USD in 1 day
(0 Reviews)