HI folks, after much reading and trial and error I have came to a
brick wall with this.
I have made a code in R GUI which had "for loops and summations
equations" that links back to sets/lines of arrays/matrix data.
But here is the problem, I have to do this in SageMath programming, so
I have to change the syntax completely

Here is the syntax, it is a shortened version of the real thing, but
the main crux of the problem i'm having is in the for loop i'm having
trouble trying to link my data in my matrix to that iterative
equation.

Thank you for all for your time and patience.
C

******I start by defining my function with two variables army.A
(Attackers) , army.D (defenders)******

tp <- function(army.A,army.D){

******so depending on how many army I got , then it assigns to the
variable a number of dice******
******, and gives it a case, in this code I gave it case 4 and 5.
******
  if (arm.A==1 & arm.D>=2)  {dice.A <- 1; dice.D <- 2; case <- 4} else
  if (arm.A==2 & arm.D>=2)  {dice.A <- 2; dice.D <- 2; case <- 5}

******These are the dice probabilities stored as a matrix******

 global.probs <- matrix(NA,ncol=6,nrow=2)
  global.probs[1,] <- rep(1,6)/6
  global.probs[2,] <-c(1,3,5,7,9,11)/36

******based on how many dice the attacker and defender have, get
the        ******
******probabilities out of the matrix, i.e. if case 4, probs,y <-
global probs[1,]******
******( the dice probability stored as a
matrix)                                            ******

  if (case==4){probs.y <- global.probs[1,]; probs.z <-
global.probs[2,]} else
  if (case==5){probs.y <- global.probs[2,]; probs.z <-
global.probs[2,]} else

******here is my for loop, a first make prob.att.win.dice1 equal to
0             ******
******
prob.att.win.dice1 <- 0

  for (y in 2:6){
    for (z in 1:(y-1)){
      prob.att.win.dice1 <- prob.att.win.dice1 + probs.y[y]*probs.z[z]
    }
  }

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to