Generated by Cython 0.14.1 on Sun May 8 10:39:35 2011

Raw output: roll_dice.c

 1: # cython: profile=True
  /* "roll_dice.pyx":1
 * # cython: profile=True             # <<<<<<<<<<<<<<
 * import  numpy as np
 * cimport numpy as np
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 2: import  numpy as np
  /* "roll_dice.pyx":2
 * # cython: profile=True
 * import  numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * import random
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 3: cimport numpy as np
 4: import random
  /* "roll_dice.pyx":4
 * import  numpy as np
 * cimport numpy as np
 * import random             # <<<<<<<<<<<<<<
 * 
 * def roll_dice1(int N, int ndice, int nsix):
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__random), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__random, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 5: 
 6: def roll_dice1(int N, int ndice, int nsix):
/* "roll_dice.pyx":6
 * import random
 * 
 * def roll_dice1(int N, int ndice, int nsix):             # <<<<<<<<<<<<<<
 *     cdef int M = 0            # no of successful events
 *     cdef int six, r
 */

static PyObject *__pyx_pf_9roll_dice_roll_dice1(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9roll_dice_roll_dice1 = {__Pyx_NAMESTR("roll_dice1"), (PyCFunction)__pyx_pf_9roll_dice_roll_dice1, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_9roll_dice_roll_dice1(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_N;
  int __pyx_v_ndice;
  int __pyx_v_nsix;
  int __pyx_v_M;
  int __pyx_v_six;
  int __pyx_v_r;
  double __pyx_v_p;
  int __pyx_v_i;
  int __pyx_v_j;
  PyObject *__pyx_r = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__N,&__pyx_n_s__ndice,&__pyx_n_s__nsix,0};
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("roll_dice1");
  __Pyx_TraceCall("roll_dice1", __pyx_f[0], 6);
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__N);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ndice);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("roll_dice1", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__nsix);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("roll_dice1", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "roll_dice1") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_N = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_N == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_ndice = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_ndice == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_nsix = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_nsix == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_N = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_N == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_ndice = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_ndice == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_nsix = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_nsix == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("roll_dice1", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("roll_dice.roll_dice1");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "roll_dice.pyx":6
 * import random
 * 
 * def roll_dice1(int N, int ndice, int nsix):             # <<<<<<<<<<<<<<
 *     cdef int M = 0            # no of successful events
 *     cdef int six, r
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_9roll_dice_roll_dice1, NULL, __pyx_n_s__roll_dice); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__roll_dice1, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 7:     cdef int M = 0            # no of successful events
  /* "roll_dice.pyx":7
 * 
 * def roll_dice1(int N, int ndice, int nsix):
 *     cdef int M = 0            # no of successful events             # <<<<<<<<<<<<<<
 *     cdef int six, r
 *     cdef double p
 */
  __pyx_v_M = 0;
 8:     cdef int six, r
 9:     cdef double p
 10:     for i in range(N):
  /* "roll_dice.pyx":10
 *     cdef int six, r
 *     cdef double p
 *     for i in range(N):             # <<<<<<<<<<<<<<
 *         six = 0               # how many dice with six eyes?
 *         for j in range(ndice):
 */
  __pyx_t_1 = __pyx_v_N;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;
 11:         six = 0               # how many dice with six eyes?
    /* "roll_dice.pyx":11
 *     cdef double p
 *     for i in range(N):
 *         six = 0               # how many dice with six eyes?             # <<<<<<<<<<<<<<
 *         for j in range(ndice):
 *             # Roll die no. j
 */
    __pyx_v_six = 0;
 12:         for j in range(ndice):
    /* "roll_dice.pyx":12
 *     for i in range(N):
 *         six = 0               # how many dice with six eyes?
 *         for j in range(ndice):             # <<<<<<<<<<<<<<
 *             # Roll die no. j
 *             r = random.randint(1, 6)
 */
    __pyx_t_3 = __pyx_v_ndice;
    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_v_j = __pyx_t_4;
 13:             # Roll die no. j
 14:             r = random.randint(1, 6)
      /* "roll_dice.pyx":14
 *         for j in range(ndice):
 *             # Roll die no. j
 *             r = random.randint(1, 6)             # <<<<<<<<<<<<<<
 *             if r == 6:
 *                six += 1
 */
      __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__random); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__randint); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_k_tuple_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_r = __pyx_t_7;

  /* "roll_dice.pyx":14
 *         for j in range(ndice):
 *             # Roll die no. j
 *             r = random.randint(1, 6)             # <<<<<<<<<<<<<<
 *             if r == 6:
 *                six += 1
 */
  __pyx_k_tuple_1 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_1));
  __Pyx_INCREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_k_tuple_1, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  __Pyx_INCREF(__pyx_int_6);
  PyTuple_SET_ITEM(__pyx_k_tuple_1, 1, __pyx_int_6);
  __Pyx_GIVEREF(__pyx_int_6);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_1));
 15:             if r == 6:
      /* "roll_dice.pyx":15
 *             # Roll die no. j
 *             r = random.randint(1, 6)
 *             if r == 6:             # <<<<<<<<<<<<<<
 *                six += 1
 *         if six >= nsix:  # Successful event?
 */
      __pyx_t_8 = (__pyx_v_r == 6);
      if (__pyx_t_8) {
 16:                six += 1
        /* "roll_dice.pyx":16
 *             r = random.randint(1, 6)
 *             if r == 6:
 *                six += 1             # <<<<<<<<<<<<<<
 *         if six >= nsix:  # Successful event?
 *             M += 1
 */
        __pyx_v_six = (__pyx_v_six + 1);
        goto __pyx_L10;
      }
      __pyx_L10:;
    }
 17:         if six >= nsix:  # Successful event?
    /* "roll_dice.pyx":17
 *             if r == 6:
 *                six += 1
 *         if six >= nsix:  # Successful event?             # <<<<<<<<<<<<<<
 *             M += 1
 *     p = float(M)/N
 */
    __pyx_t_8 = (__pyx_v_six >= __pyx_v_nsix);
    if (__pyx_t_8) {
 18:             M += 1
      /* "roll_dice.pyx":18
 *                six += 1
 *         if six >= nsix:  # Successful event?
 *             M += 1             # <<<<<<<<<<<<<<
 *     p = float(M)/N
 *     return p
 */
      __pyx_v_M = (__pyx_v_M + 1);
      goto __pyx_L11;
    }
    __pyx_L11:;
  }
 19:     p = float(M)/N
  /* "roll_dice.pyx":19
 *         if six >= nsix:  # Successful event?
 *             M += 1
 *     p = float(M)/N             # <<<<<<<<<<<<<<
 *     return p
 * 
 */
  if (unlikely(__pyx_v_N == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_p = (((double)__pyx_v_M) / __pyx_v_N);
 20:     return p
  /* "roll_dice.pyx":20
 *             M += 1
 *     p = float(M)/N
 *     return p             # <<<<<<<<<<<<<<
 * 
 * import cython
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_p); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("roll_dice.roll_dice1");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 21: 
 22: import cython
 23: @cython.boundscheck(False)
 24: def roll_dice2(int N, int ndice, int nsix):
/* "roll_dice.pyx":24
 * import cython
 * @cython.boundscheck(False)
 * def roll_dice2(int N, int ndice, int nsix):             # <<<<<<<<<<<<<<
 *     # Use numpy to generate all random numbers
 *     cdef int M = 0            # no of successful events
 */

static PyObject *__pyx_pf_9roll_dice_1roll_dice2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9roll_dice_1roll_dice2 = {__Pyx_NAMESTR("roll_dice2"), (PyCFunction)__pyx_pf_9roll_dice_1roll_dice2, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_9roll_dice_1roll_dice2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_N;
  int __pyx_v_ndice;
  int __pyx_v_nsix;
  int __pyx_v_M;
  int __pyx_v_six;
  int __pyx_v_r;
  double __pyx_v_p;
  PyArrayObject *__pyx_v_eyes = 0;
  int __pyx_v_i;
  int __pyx_v_j;
  Py_buffer __pyx_bstruct_eyes;
  Py_ssize_t __pyx_bstride_0_eyes = 0;
  Py_ssize_t __pyx_bstride_1_eyes = 0;
  Py_ssize_t __pyx_bshape_0_eyes = 0;
  Py_ssize_t __pyx_bshape_1_eyes = 0;
  PyObject *__pyx_r = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__N,&__pyx_n_s__ndice,&__pyx_n_s__nsix,0};
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("roll_dice2");
  __Pyx_TraceCall("roll_dice2", __pyx_f[0], 24);
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__N);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ndice);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("roll_dice2", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__nsix);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("roll_dice2", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "roll_dice2") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_N = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_N == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_ndice = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_ndice == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_nsix = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_nsix == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_N = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_N == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_ndice = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_ndice == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_nsix = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_nsix == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("roll_dice2", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("roll_dice.roll_dice2");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_bstruct_eyes.buf = NULL;

  /* "roll_dice.pyx":24
 * import cython
 * @cython.boundscheck(False)
 * def roll_dice2(int N, int ndice, int nsix):             # <<<<<<<<<<<<<<
 *     # Use numpy to generate all random numbers
 *     cdef int M = 0            # no of successful events
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_9roll_dice_1roll_dice2, NULL, __pyx_n_s__roll_dice); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__roll_dice2, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 25:     # Use numpy to generate all random numbers
 26:     cdef int M = 0            # no of successful events
  /* "roll_dice.pyx":26
 * def roll_dice2(int N, int ndice, int nsix):
 *     # Use numpy to generate all random numbers
 *     cdef int M = 0            # no of successful events             # <<<<<<<<<<<<<<
 *     cdef int six, r
 *     cdef double p
 */
  __pyx_v_M = 0;
 27:     cdef int six, r
 28:     cdef double p
 29:     cdef np.ndarray[np.int_t, ndim=2, negative_indices=False,
 30:                     mode='c'] eyes = np.random.random_integers(1, 6, (N, ndice))
  /* "roll_dice.pyx":30
 *     cdef double p
 *     cdef np.ndarray[np.int_t, ndim=2, negative_indices=False,
 *                     mode='c'] eyes = np.random.random_integers(1, 6, (N, ndice))             # <<<<<<<<<<<<<<
 *     for i in range(N):
 *         six = 0               # how many dice with six eyes?
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__random_integers); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromLong(__pyx_v_N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyInt_FromLong(__pyx_v_ndice); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  __Pyx_INCREF(__pyx_int_6);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_6);
  __Pyx_GIVEREF(__pyx_int_6);
  PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_t_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_eyes, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_eyes = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_eyes.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_eyes = __pyx_bstruct_eyes.strides[0]; __pyx_bstride_1_eyes = __pyx_bstruct_eyes.strides[1];
      __pyx_bshape_0_eyes = __pyx_bstruct_eyes.shape[0]; __pyx_bshape_1_eyes = __pyx_bstruct_eyes.shape[1];
    }
  }
  __pyx_t_5 = 0;
  __pyx_v_eyes = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;
 31:     for i in range(N):
  /* "roll_dice.pyx":31
 *     cdef np.ndarray[np.int_t, ndim=2, negative_indices=False,
 *                     mode='c'] eyes = np.random.random_integers(1, 6, (N, ndice))
 *     for i in range(N):             # <<<<<<<<<<<<<<
 *         six = 0               # how many dice with six eyes?
 *         for j in range(ndice):
 */
  __pyx_t_6 = __pyx_v_N;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;
 32:         six = 0               # how many dice with six eyes?
    /* "roll_dice.pyx":32
 *                     mode='c'] eyes = np.random.random_integers(1, 6, (N, ndice))
 *     for i in range(N):
 *         six = 0               # how many dice with six eyes?             # <<<<<<<<<<<<<<
 *         for j in range(ndice):
 *             # Roll die no. j
 */
    __pyx_v_six = 0;
 33:         for j in range(ndice):
    /* "roll_dice.pyx":33
 *     for i in range(N):
 *         six = 0               # how many dice with six eyes?
 *         for j in range(ndice):             # <<<<<<<<<<<<<<
 *             # Roll die no. j
 *             r = eyes[i,j]
 */
    __pyx_t_8 = __pyx_v_ndice;
    for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
      __pyx_v_j = __pyx_t_9;
 34:             # Roll die no. j
 35:             r = eyes[i,j]
      /* "roll_dice.pyx":35
 *         for j in range(ndice):
 *             # Roll die no. j
 *             r = eyes[i,j]             # <<<<<<<<<<<<<<
 *             if r == 6:
 *                six += 1
 */
      __pyx_t_10 = __pyx_v_i;
      __pyx_t_11 = __pyx_v_j;
      __pyx_v_r = (*__Pyx_BufPtrCContig2d(__pyx_t_5numpy_int_t *, __pyx_bstruct_eyes.buf, __pyx_t_10, __pyx_bstride_0_eyes, __pyx_t_11, __pyx_bstride_1_eyes));
 36:             if r == 6:
      /* "roll_dice.pyx":36
 *             # Roll die no. j
 *             r = eyes[i,j]
 *             if r == 6:             # <<<<<<<<<<<<<<
 *                six += 1
 *         if six >= nsix:  # Successful event?
 */
      __pyx_t_12 = (__pyx_v_r == 6);
      if (__pyx_t_12) {
 37:                six += 1
        /* "roll_dice.pyx":37
 *             r = eyes[i,j]
 *             if r == 6:
 *                six += 1             # <<<<<<<<<<<<<<
 *         if six >= nsix:  # Successful event?
 *             M += 1
 */
        __pyx_v_six = (__pyx_v_six + 1);
        goto __pyx_L10;
      }
      __pyx_L10:;
    }
 38:         if six >= nsix:  # Successful event?
    /* "roll_dice.pyx":38
 *             if r == 6:
 *                six += 1
 *         if six >= nsix:  # Successful event?             # <<<<<<<<<<<<<<
 *             M += 1
 *     p = float(M)/N
 */
    __pyx_t_12 = (__pyx_v_six >= __pyx_v_nsix);
    if (__pyx_t_12) {
 39:             M += 1
      /* "roll_dice.pyx":39
 *                six += 1
 *         if six >= nsix:  # Successful event?
 *             M += 1             # <<<<<<<<<<<<<<
 *     p = float(M)/N
 *     return p
 */
      __pyx_v_M = (__pyx_v_M + 1);
      goto __pyx_L11;
    }
    __pyx_L11:;
  }
 40:     p = float(M)/N
  /* "roll_dice.pyx":40
 *         if six >= nsix:  # Successful event?
 *             M += 1
 *     p = float(M)/N             # <<<<<<<<<<<<<<
 *     return p
 * 
 */
  if (unlikely(__pyx_v_N == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_p = (((double)__pyx_v_M) / __pyx_v_N);
 41:     return p
  /* "roll_dice.pyx":41
 *             M += 1
 *     p = float(M)/N
 *     return p             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_p); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_eyes);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("roll_dice.roll_dice2");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_eyes);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_eyes);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 42: 
 43: