/* Generated by Cython 0.23 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "depends": [
            "/home/jmschr/anaconda/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h", 
            "/home/jmschr/anaconda/lib/python2.7/site-packages/numpy/core/include/numpy/ufuncobject.h"
        ], 
        "include_dirs": [
            "/home/jmschr/anaconda/lib/python2.7/site-packages/numpy/core/include"
        ]
    }
}
END: Cython Metadata */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
    #error Cython requires Python 2.6+ or Python 3.2+.
#else
#define CYTHON_ABI "0_23"
#include <stddef.h>
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif
#if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000
#define CYTHON_USE_PYLONG_INTERNALS 1
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
#define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
#else
  #define CYTHON_PEP393_ENABLED 0
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if PY_VERSION_HEX >= 0x030500B1
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
#elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
typedef struct {
    unaryfunc am_await;
    unaryfunc am_aiter;
    unaryfunc am_anext;
} __Pyx_PyAsyncMethodsStruct;
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
#else
#define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#define __Pyx_void_to_None(void_result) (void_result, Py_INCREF(Py_None), Py_None)

#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
  #define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif


#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#define __PYX_HAVE__pomegranate__distributions
#define __PYX_HAVE_API__pomegranate__distributions
#include "string.h"
#include "stdio.h"
#include "stdlib.h"
#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"
#include "math.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif

#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
    (sizeof(type) < sizeof(Py_ssize_t))  ||\
    (sizeof(type) > sizeof(Py_ssize_t) &&\
          likely(v < (type)PY_SSIZE_T_MAX ||\
                 v == (type)PY_SSIZE_T_MAX)  &&\
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
                                v == (type)PY_SSIZE_T_MIN)))  ||\
    (sizeof(type) == sizeof(Py_ssize_t) &&\
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
                               v == (type)PY_SSIZE_T_MAX)))  )
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (_MSC_VER) && defined (_M_X64)
    #define __Pyx_sst_abs(value) _abs64(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
{
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#else
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
#endif
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_COMPILING_IN_CPYTHON
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */

static PyObject *__pyx_m;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;

#if !defined(CYTHON_CCOMPLEX)
  #if defined(__cplusplus)
    #define CYTHON_CCOMPLEX 1
  #elif defined(_Complex_I)
    #define CYTHON_CCOMPLEX 1
  #else
    #define CYTHON_CCOMPLEX 0
  #endif
#endif
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #include <complex>
  #else
    #include <complex.h>
  #endif
#endif
#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
  #undef _Complex_I
  #define _Complex_I 1.0fj
#endif


static const char *__pyx_f[] = {
  "pomegranate/distributions.pyx",
  "pomegranate/distributions.pxd",
  "__init__.pxd",
  "type.pxd",
};

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":725
 * # in Cython to enable them only on the right systems.
 * 
 * ctypedef npy_int8       int8_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t
 */
typedef npy_int8 __pyx_t_5numpy_int8_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":726
 * 
 * ctypedef npy_int8       int8_t
 * ctypedef npy_int16      int16_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int32      int32_t
 * ctypedef npy_int64      int64_t
 */
typedef npy_int16 __pyx_t_5numpy_int16_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":727
 * ctypedef npy_int8       int8_t
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int64      int64_t
 * #ctypedef npy_int96      int96_t
 */
typedef npy_int32 __pyx_t_5numpy_int32_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":728
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t
 * ctypedef npy_int64      int64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_int96      int96_t
 * #ctypedef npy_int128     int128_t
 */
typedef npy_int64 __pyx_t_5numpy_int64_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":732
 * #ctypedef npy_int128     int128_t
 * 
 * ctypedef npy_uint8      uint8_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t
 */
typedef npy_uint8 __pyx_t_5numpy_uint8_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":733
 * 
 * ctypedef npy_uint8      uint8_t
 * ctypedef npy_uint16     uint16_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint32     uint32_t
 * ctypedef npy_uint64     uint64_t
 */
typedef npy_uint16 __pyx_t_5numpy_uint16_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":734
 * ctypedef npy_uint8      uint8_t
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint64     uint64_t
 * #ctypedef npy_uint96     uint96_t
 */
typedef npy_uint32 __pyx_t_5numpy_uint32_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":735
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t
 * ctypedef npy_uint64     uint64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_uint96     uint96_t
 * #ctypedef npy_uint128    uint128_t
 */
typedef npy_uint64 __pyx_t_5numpy_uint64_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":739
 * #ctypedef npy_uint128    uint128_t
 * 
 * ctypedef npy_float32    float32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_float64    float64_t
 * #ctypedef npy_float80    float80_t
 */
typedef npy_float32 __pyx_t_5numpy_float32_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":740
 * 
 * ctypedef npy_float32    float32_t
 * ctypedef npy_float64    float64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_float80    float80_t
 * #ctypedef npy_float128   float128_t
 */
typedef npy_float64 __pyx_t_5numpy_float64_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":749
 * # The int types are mapped a bit surprising --
 * # numpy.int corresponds to 'l' and numpy.long to 'q'
 * ctypedef npy_long       int_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longlong   long_t
 * ctypedef npy_longlong   longlong_t
 */
typedef npy_long __pyx_t_5numpy_int_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":750
 * # numpy.int corresponds to 'l' and numpy.long to 'q'
 * ctypedef npy_long       int_t
 * ctypedef npy_longlong   long_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longlong   longlong_t
 * 
 */
typedef npy_longlong __pyx_t_5numpy_long_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":751
 * ctypedef npy_long       int_t
 * ctypedef npy_longlong   long_t
 * ctypedef npy_longlong   longlong_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_ulong      uint_t
 */
typedef npy_longlong __pyx_t_5numpy_longlong_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":753
 * ctypedef npy_longlong   longlong_t
 * 
 * ctypedef npy_ulong      uint_t             # <<<<<<<<<<<<<<
 * ctypedef npy_ulonglong  ulong_t
 * ctypedef npy_ulonglong  ulonglong_t
 */
typedef npy_ulong __pyx_t_5numpy_uint_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":754
 * 
 * ctypedef npy_ulong      uint_t
 * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 */
typedef npy_ulonglong __pyx_t_5numpy_ulong_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":755
 * ctypedef npy_ulong      uint_t
 * ctypedef npy_ulonglong  ulong_t
 * ctypedef npy_ulonglong  ulonglong_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_intp       intp_t
 */
typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":757
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uintp      uintp_t
 * 
 */
typedef npy_intp __pyx_t_5numpy_intp_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":758
 * 
 * ctypedef npy_intp       intp_t
 * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_double     float_t
 */
typedef npy_uintp __pyx_t_5numpy_uintp_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":760
 * ctypedef npy_uintp      uintp_t
 * 
 * ctypedef npy_double     float_t             # <<<<<<<<<<<<<<
 * ctypedef npy_double     double_t
 * ctypedef npy_longdouble longdouble_t
 */
typedef npy_double __pyx_t_5numpy_float_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":761
 * 
 * ctypedef npy_double     float_t
 * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longdouble longdouble_t
 * 
 */
typedef npy_double __pyx_t_5numpy_double_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":762
 * ctypedef npy_double     float_t
 * ctypedef npy_double     double_t
 * ctypedef npy_longdouble longdouble_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_cfloat      cfloat_t
 */
typedef npy_longdouble __pyx_t_5numpy_longdouble_t;

/* "pomegranate/distributions.pxd":6
 * cimport numpy
 * 
 * ctypedef numpy.npy_float64 DOUBLE_t             # <<<<<<<<<<<<<<
 * ctypedef numpy.npy_intp SIZE_t
 * 
 */
typedef npy_float64 __pyx_t_11pomegranate_13distributions_DOUBLE_t;

/* "pomegranate/distributions.pxd":7
 * 
 * ctypedef numpy.npy_float64 DOUBLE_t
 * ctypedef numpy.npy_intp SIZE_t             # <<<<<<<<<<<<<<
 * 
 * cdef class Distribution:
 */
typedef npy_intp __pyx_t_11pomegranate_13distributions_SIZE_t;
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< float > __pyx_t_float_complex;
  #else
    typedef float _Complex __pyx_t_float_complex;
  #endif
#else
    typedef struct { float real, imag; } __pyx_t_float_complex;
#endif

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< double > __pyx_t_double_complex;
  #else
    typedef double _Complex __pyx_t_double_complex;
  #endif
#else
    typedef struct { double real, imag; } __pyx_t_double_complex;
#endif


/*--- Type declarations ---*/
struct __pyx_obj_11pomegranate_13distributions_Distribution;
struct __pyx_obj_11pomegranate_13distributions_UniformDistribution;
struct __pyx_obj_11pomegranate_13distributions_NormalDistribution;
struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution;
struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution;
struct __pyx_obj_11pomegranate_13distributions_BetaDistribution;
struct __pyx_obj_11pomegranate_13distributions_GammaDistribution;
struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution;
struct __pyx_obj_11pomegranate_13distributions_LambdaDistribution;
struct __pyx_obj_11pomegranate_13distributions_KernelDensity;
struct __pyx_obj_11pomegranate_13distributions_GaussianKernelDensity;
struct __pyx_obj_11pomegranate_13distributions_UniformKernelDensity;
struct __pyx_obj_11pomegranate_13distributions_TriangleKernelDensity;
struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution;
struct __pyx_obj_11pomegranate_13distributions_MultivariateDistribution;
struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution;
struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution;
struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable;
struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable;
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__;
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr;
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys;
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr;
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint;
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr;
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__;
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr;
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys;
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":764
 * ctypedef npy_longdouble longdouble_t
 * 
 * ctypedef npy_cfloat      cfloat_t             # <<<<<<<<<<<<<<
 * ctypedef npy_cdouble     cdouble_t
 * ctypedef npy_clongdouble clongdouble_t
 */
typedef npy_cfloat __pyx_t_5numpy_cfloat_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":765
 * 
 * ctypedef npy_cfloat      cfloat_t
 * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
 * ctypedef npy_clongdouble clongdouble_t
 * 
 */
typedef npy_cdouble __pyx_t_5numpy_cdouble_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":766
 * ctypedef npy_cfloat      cfloat_t
 * ctypedef npy_cdouble     cdouble_t
 * ctypedef npy_clongdouble clongdouble_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_cdouble     complex_t
 */
typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":768
 * ctypedef npy_clongdouble clongdouble_t
 * 
 * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew1(a):
 */
typedef npy_cdouble __pyx_t_5numpy_complex_t;

/* "pomegranate/distributions.pxd":9
 * ctypedef numpy.npy_intp SIZE_t
 * 
 * cdef class Distribution:             # <<<<<<<<<<<<<<
 * 	cdef public str name
 * 	cdef public list summaries
 */
struct __pyx_obj_11pomegranate_13distributions_Distribution {
  PyObject_HEAD
  struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution *__pyx_vtab;
  PyObject *name;
  PyObject *summaries;
  int frozen;
};


/* "pomegranate/distributions.pxd":17
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil
 * 
 * cdef class UniformDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	cdef double start, end
 * 
 */
struct __pyx_obj_11pomegranate_13distributions_UniformDistribution {
  struct __pyx_obj_11pomegranate_13distributions_Distribution __pyx_base;
  double start;
  double end;
};


/* "pomegranate/distributions.pxd":20
 * 	cdef double start, end
 * 
 * cdef class NormalDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	cdef double mu, sigma, two_sigma_squared, log_sigma_sqrt_2_pi
 * 
 */
struct __pyx_obj_11pomegranate_13distributions_NormalDistribution {
  struct __pyx_obj_11pomegranate_13distributions_Distribution __pyx_base;
  double mu;
  double sigma;
  double two_sigma_squared;
  double log_sigma_sqrt_2_pi;
};


/* "pomegranate/distributions.pxd":23
 * 	cdef double mu, sigma, two_sigma_squared, log_sigma_sqrt_2_pi
 * 
 * cdef class LogNormalDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	cdef double mu, sigma
 * 
 */
struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution {
  struct __pyx_obj_11pomegranate_13distributions_Distribution __pyx_base;
  double mu;
  double sigma;
};


/* "pomegranate/distributions.pxd":26
 * 	cdef double mu, sigma
 * 
 * cdef class ExponentialDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	cdef double rate
 * 
 */
struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution {
  struct __pyx_obj_11pomegranate_13distributions_Distribution __pyx_base;
  double rate;
};


/* "pomegranate/distributions.pxd":29
 * 	cdef double rate
 * 
 * cdef class BetaDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	cdef double alpha, beta
 * 
 */
struct __pyx_obj_11pomegranate_13distributions_BetaDistribution {
  struct __pyx_obj_11pomegranate_13distributions_Distribution __pyx_base;
  double alpha;
  double beta;
};


/* "pomegranate/distributions.pxd":32
 * 	cdef double alpha, beta
 * 
 * cdef class GammaDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	cdef double alpha, beta
 * 
 */
struct __pyx_obj_11pomegranate_13distributions_GammaDistribution {
  struct __pyx_obj_11pomegranate_13distributions_Distribution __pyx_base;
  double alpha;
  double beta;
};


/* "pomegranate/distributions.pxd":35
 * 	cdef double alpha, beta
 * 
 * cdef class DiscreteDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	cdef bint encoded_summary
 * 	cdef int n
 */
struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution {
  struct __pyx_obj_11pomegranate_13distributions_Distribution __pyx_base;
  int encoded_summary;
  int n;
  PyObject *dist;
  PyObject *log_dist;
  PyObject *encoded_keys;
  double *encoded_counts;
  double *encoded_log_probability;
};


/* "pomegranate/distributions.pxd":44
 * 	cdef double __log_probability( self, symbol )
 * 
 * cdef class LambdaDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	pass
 * 
 */
struct __pyx_obj_11pomegranate_13distributions_LambdaDistribution {
  struct __pyx_obj_11pomegranate_13distributions_Distribution __pyx_base;
};


/* "pomegranate/distributions.pxd":47
 * 	pass
 * 
 * cdef class KernelDensity( Distribution ):             # <<<<<<<<<<<<<<
 * 	cdef numpy.ndarray points_ndarray, weights_ndarray
 * 	cdef double* points
 */
struct __pyx_obj_11pomegranate_13distributions_KernelDensity {
  struct __pyx_obj_11pomegranate_13distributions_Distribution __pyx_base;
  PyArrayObject *points_ndarray;
  PyArrayObject *weights_ndarray;
  double *points;
  double *weights;
  int n;
  double bandwidth;
};


/* "pomegranate/distributions.pxd":54
 * 	cdef double bandwidth
 * 
 * cdef class GaussianKernelDensity( KernelDensity ):             # <<<<<<<<<<<<<<
 * 	pass
 * 
 */
struct __pyx_obj_11pomegranate_13distributions_GaussianKernelDensity {
  struct __pyx_obj_11pomegranate_13distributions_KernelDensity __pyx_base;
};


/* "pomegranate/distributions.pxd":57
 * 	pass
 * 
 * cdef class UniformKernelDensity( KernelDensity ):             # <<<<<<<<<<<<<<
 * 	pass
 * 
 */
struct __pyx_obj_11pomegranate_13distributions_UniformKernelDensity {
  struct __pyx_obj_11pomegranate_13distributions_KernelDensity __pyx_base;
};


/* "pomegranate/distributions.pxd":60
 * 	pass
 * 
 * cdef class TriangleKernelDensity( KernelDensity ):             # <<<<<<<<<<<<<<
 * 	pass
 * 
 */
struct __pyx_obj_11pomegranate_13distributions_TriangleKernelDensity {
  struct __pyx_obj_11pomegranate_13distributions_KernelDensity __pyx_base;
};


/* "pomegranate/distributions.pxd":63
 * 	pass
 * 
 * cdef class MixtureDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	cdef double* weights_p
 * 	cdef numpy.ndarray distributions, weights
 */
struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution {
  struct __pyx_obj_11pomegranate_13distributions_Distribution __pyx_base;
  double *weights_p;
  PyArrayObject *distributions;
  PyArrayObject *weights;
  int n;
};


/* "pomegranate/distributions.pxd":68
 * 	cdef int n
 * 
 * cdef class MultivariateDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	cdef public SIZE_t d
 * 
 */
struct __pyx_obj_11pomegranate_13distributions_MultivariateDistribution {
  struct __pyx_obj_11pomegranate_13distributions_Distribution __pyx_base;
  __pyx_t_11pomegranate_13distributions_SIZE_t d;
};


/* "pomegranate/distributions.pxd":71
 * 	cdef public SIZE_t d
 * 
 * cdef class IndependentComponentsDistribution( MultivariateDistribution ):             # <<<<<<<<<<<<<<
 * 	cdef numpy.ndarray distributions, weights
 * 
 */
struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution {
  struct __pyx_obj_11pomegranate_13distributions_MultivariateDistribution __pyx_base;
  PyArrayObject *distributions;
  PyArrayObject *weights;
};


/* "pomegranate/distributions.pxd":74
 * 	cdef numpy.ndarray distributions, weights
 * 
 * cdef class MultivariateGaussianDistribution( MultivariateDistribution ):             # <<<<<<<<<<<<<<
 * 	cdef public numpy.ndarray mu, cov, inv_cov_ndarray
 * 	cdef double* inv_cov
 */
struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution {
  struct __pyx_obj_11pomegranate_13distributions_MultivariateDistribution __pyx_base;
  PyArrayObject *mu;
  PyArrayObject *cov;
  PyArrayObject *inv_cov_ndarray;
  double *inv_cov;
  double *_mu;
  double *_mu_new;
  double *_cov;
  double *_cov_new;
  double _log_det;
  double w_sum;
  double *column_sum;
  double *pair_sum;
};


/* "pomegranate/distributions.pxd":87
 * 	cdef void _from_summaries( self, double inertia )
 * 
 * cdef class ConditionalProbabilityTable( MultivariateDistribution ):             # <<<<<<<<<<<<<<
 * 	cdef public list parameters
 * 
 */
struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable {
  struct __pyx_obj_11pomegranate_13distributions_MultivariateDistribution __pyx_base;
  PyObject *parameters;
};


/* "pomegranate/distributions.pxd":90
 * 	cdef public list parameters
 * 
 * cdef class JointProbabilityTable( MultivariateDistribution ):             # <<<<<<<<<<<<<<
 * 	cdef public list parameters
 */
struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable {
  struct __pyx_obj_11pomegranate_13distributions_MultivariateDistribution __pyx_base;
  PyObject *parameters;
};


/* "pomegranate/distributions.pyx":2009
 * 			self.parameters = [ values, parents, keys ]
 * 
 * 	def __str__( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Regenerate the table.
 */
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__ {
  PyObject_HEAD
  PyObject *__pyx_v_keys;
  PyObject *__pyx_v_values;
};


/* "pomegranate/distributions.pyx":2016
 * 		values, parents, keys = self.parameters
 * 		return "\n".join(
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )             # <<<<<<<<<<<<<<
 * 							for key, idx in keys.items() )
 * 
 */
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr {
  PyObject_HEAD
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__ *__pyx_outer_scope;
  PyObject *__pyx_v_idx;
  PyObject *__pyx_v_key;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pomegranate/distributions.pyx":2026
 * 		return len( self.keys() )
 * 
 * 	def keys( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Return the keys of the probability distribution which has parents,
 */
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys {
  PyObject_HEAD
  struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self;
};


/* "pomegranate/distributions.pyx":2032
 * 		"""
 * 
 * 		return tuple(set(row[-1] for row in self.parameters[2].keys()))             # <<<<<<<<<<<<<<
 * 
 * 	def log_probability( self, symbol ):
 */
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr {
  PyObject_HEAD
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys *__pyx_outer_scope;
  PyObject *__pyx_v_row;
};


/* "pomegranate/distributions.pyx":2046
 * 		return values[ keys[symbol] ]
 * 
 * 	def joint( self, neighbor_values=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		This will turn a conditional probability table into a joint
 */
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint {
  PyObject_HEAD
  PyObject *__pyx_v_table;
};


/* "pomegranate/distributions.pyx":2091
 * 
 * 		# Normalize the values
 * 		total = sum( row[-1] for row in table )             # <<<<<<<<<<<<<<
 * 		table = [ row[:-1] + (row[-1] / total,) for row in table ]
 * 
 */
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr {
  PyObject_HEAD
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint *__pyx_outer_scope;
  PyObject *__pyx_v_row;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
};


/* "pomegranate/distributions.pyx":2183
 * 			self.parameters = [ values, neighbors, keys ]
 * 
 * 	def __str__( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Regenerate the table.
 */
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__ {
  PyObject_HEAD
  PyObject *__pyx_v_keys;
  PyObject *__pyx_v_values;
};


/* "pomegranate/distributions.pyx":2190
 * 		values, parents, keys = self.parameters
 * 		return "\n".join(
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )             # <<<<<<<<<<<<<<
 * 							for key, idx in keys.items() )
 * 
 */
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr {
  PyObject_HEAD
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__ *__pyx_outer_scope;
  PyObject *__pyx_v_idx;
  PyObject *__pyx_v_key;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pomegranate/distributions.pyx":2200
 * 		return len( self.keys() )
 * 
 * 	def keys( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Return the keys of the probability distribution which has parents,
 */
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys {
  PyObject_HEAD
  struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self;
};


/* "pomegranate/distributions.pyx":2206
 * 		"""
 * 
 * 		return tuple(set(row[-1] for row in self.parameters[2].keys()))             # <<<<<<<<<<<<<<
 * 
 * 	def log_probability( self, symbol ):
 */
struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr {
  PyObject_HEAD
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys *__pyx_outer_scope;
  PyObject *__pyx_v_row;
};



/* "pomegranate/distributions.pyx":69
 * 	return items, weights
 * 
 * cdef class Distribution:             # <<<<<<<<<<<<<<
 * 	"""
 * 	Represents a probability distribution over whatever the HMM you're making is
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution {
  double (*_log_probability)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double);
  double (*_mv_log_probability)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double *);
  void (*_summarize)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double *, double *, __pyx_t_11pomegranate_13distributions_SIZE_t);
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution *__pyx_vtabptr_11pomegranate_13distributions_Distribution;


/* "pomegranate/distributions.pyx":236
 * 
 * 
 * cdef class UniformDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	"""A uniform distribution between two values."""
 * 
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_UniformDistribution {
  struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution __pyx_base;
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_UniformDistribution *__pyx_vtabptr_11pomegranate_13distributions_UniformDistribution;


/* "pomegranate/distributions.pyx":337
 * 
 * 
 * cdef class NormalDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	A normal distribution based on a mean and standard deviation.
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_NormalDistribution {
  struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution __pyx_base;
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_NormalDistribution *__pyx_vtabptr_11pomegranate_13distributions_NormalDistribution;


/* "pomegranate/distributions.pyx":444
 * 		self.two_sigma_squared = 2 * sigma ** 2
 * 
 * cdef class LogNormalDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	Represents a lognormal distribution over non-negative floats.
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_LogNormalDistribution {
  struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution __pyx_base;
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_LogNormalDistribution *__pyx_vtabptr_11pomegranate_13distributions_LogNormalDistribution;


/* "pomegranate/distributions.pyx":552
 * 		self.summaries = [0, 0, 0]
 * 
 * cdef class ExponentialDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	Represents an exponential distribution on non-negative floats.
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_ExponentialDistribution {
  struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution __pyx_base;
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_ExponentialDistribution *__pyx_vtabptr_11pomegranate_13distributions_ExponentialDistribution;


/* "pomegranate/distributions.pyx":640
 * 
 * 
 * cdef class BetaDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	This distribution represents a beta distribution, parameterized using
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_BetaDistribution {
  struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution __pyx_base;
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_BetaDistribution *__pyx_vtabptr_11pomegranate_13distributions_BetaDistribution;


/* "pomegranate/distributions.pyx":735
 * 		self.summaries = []
 * 
 * cdef class GammaDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	This distribution represents a gamma distribution, parameterized in the
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_GammaDistribution {
  struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution __pyx_base;
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_GammaDistribution *__pyx_vtabptr_11pomegranate_13distributions_GammaDistribution;


/* "pomegranate/distributions.pyx":1016
 * 		self.summaries = []
 * 
 * cdef class DiscreteDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	A discrete distribution, made up of characters and their probabilities,
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_DiscreteDistribution {
  struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution __pyx_base;
  double (*__pyx___log_probability)(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *, PyObject *);
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_DiscreteDistribution *__pyx_vtabptr_11pomegranate_13distributions_DiscreteDistribution;


/* "pomegranate/distributions.pyx":1226
 * 
 * 
 * cdef class LambdaDistribution(Distribution):             # <<<<<<<<<<<<<<
 * 	"""
 * 	A distribution which takes in an arbitrary lambda function, and returns
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_LambdaDistribution {
  struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution __pyx_base;
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_LambdaDistribution *__pyx_vtabptr_11pomegranate_13distributions_LambdaDistribution;


/* "pomegranate/distributions.pyx":1258
 * 		return self.parameters[0](symbol)
 * 
 * cdef class KernelDensity( Distribution ):             # <<<<<<<<<<<<<<
 * 	"""An abstract kernel density, with shared properties and methods."""
 * 
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_KernelDensity {
  struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution __pyx_base;
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_KernelDensity *__pyx_vtabptr_11pomegranate_13distributions_KernelDensity;


/* "pomegranate/distributions.pyx":1331
 * 		self.weights = <double*> self.weights_ndarray.data
 * 
 * cdef class GaussianKernelDensity( KernelDensity ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	A quick way of storing points to represent a Gaussian kernel density in one
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_GaussianKernelDensity {
  struct __pyx_vtabstruct_11pomegranate_13distributions_KernelDensity __pyx_base;
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_GaussianKernelDensity *__pyx_vtabptr_11pomegranate_13distributions_GaussianKernelDensity;


/* "pomegranate/distributions.pyx":1373
 * 		return random.gauss( mu, self.parameters[1] )
 * 
 * cdef class UniformKernelDensity( KernelDensity ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	A quick way of storing points to represent an Exponential kernel density in
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_UniformKernelDensity {
  struct __pyx_vtabstruct_11pomegranate_13distributions_KernelDensity __pyx_base;
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_UniformKernelDensity *__pyx_vtabptr_11pomegranate_13distributions_UniformKernelDensity;


/* "pomegranate/distributions.pyx":1423
 * 		return random.uniform( mu-bandwidth, mu+bandwidth )
 * 
 * cdef class TriangleKernelDensity( KernelDensity ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	A quick way of storing points to represent an Exponential kernel density in
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_TriangleKernelDensity {
  struct __pyx_vtabstruct_11pomegranate_13distributions_KernelDensity __pyx_base;
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_TriangleKernelDensity *__pyx_vtabptr_11pomegranate_13distributions_TriangleKernelDensity;


/* "pomegranate/distributions.pyx":1472
 * 		return random.triangular( mu-bandwidth, mu+bandwidth, mu )
 * 
 * cdef class MixtureDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	Allows you to create an arbitrary mixture of distributions. There can be
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_MixtureDistribution {
  struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution __pyx_base;
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_MixtureDistribution *__pyx_vtabptr_11pomegranate_13distributions_MixtureDistribution;


/* "pomegranate/distributions.pyx":1649
 * 						   }, separators=(',', ' : ' ), indent=4 )
 * 
 * cdef class MultivariateDistribution( Distribution ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	An object to easily identify multivariate distributions such as tables.
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_MultivariateDistribution {
  struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution __pyx_base;
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_MultivariateDistribution *__pyx_vtabptr_11pomegranate_13distributions_MultivariateDistribution;


/* "pomegranate/distributions.pyx":1656
 * 	pass
 * 
 * cdef class IndependentComponentsDistribution( MultivariateDistribution ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	Allows you to create a multivariate distribution, where each distribution
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_IndependentComponentsDistribution {
  struct __pyx_vtabstruct_11pomegranate_13distributions_MultivariateDistribution __pyx_base;
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_vtabptr_11pomegranate_13distributions_IndependentComponentsDistribution;


/* "pomegranate/distributions.pyx":1790
 * 
 * 
 * cdef class MultivariateGaussianDistribution( MultivariateDistribution ):             # <<<<<<<<<<<<<<
 * 
 * 	property parameters:
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_MultivariateGaussianDistribution {
  struct __pyx_vtabstruct_11pomegranate_13distributions_MultivariateDistribution __pyx_base;
  void (*_from_summaries)(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *, double);
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_vtabptr_11pomegranate_13distributions_MultivariateGaussianDistribution;


/* "pomegranate/distributions.pyx":1979
 * 		self._log_det = _log( numpy.linalg.det( self.cov ) )
 * 
 * cdef class ConditionalProbabilityTable( MultivariateDistribution ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	A conditional probability table, which is dependent on values from at
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_ConditionalProbabilityTable {
  struct __pyx_vtabstruct_11pomegranate_13distributions_MultivariateDistribution __pyx_base;
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_vtabptr_11pomegranate_13distributions_ConditionalProbabilityTable;


/* "pomegranate/distributions.pyx":2152
 * 
 * 
 * cdef class JointProbabilityTable( MultivariateDistribution ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	A joint probability table. The primary difference between this and the
 */

struct __pyx_vtabstruct_11pomegranate_13distributions_JointProbabilityTable {
  struct __pyx_vtabstruct_11pomegranate_13distributions_MultivariateDistribution __pyx_base;
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_JointProbabilityTable *__pyx_vtabptr_11pomegranate_13distributions_JointProbabilityTable;

/* --- Runtime support code (head) --- */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          if (acquire_gil) {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
              PyGILState_Release(__pyx_gilstate_save);\
          } else {\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext()\
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

static PyObject *__Pyx_GetBuiltinName(PyObject *name);

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_EqObjC(op1, op2, intval, inplace)\
    PyObject_RichCompare(op1, op2, Py_EQ)
    #endif

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
    const char* function_name);

#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb);

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len)) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif

static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

#include <string.h>

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif

#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
               __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
                                               int is_list, int wraparound, int boundscheck);

#if PY_MAJOR_VERSION < 3
#define __Pyx_PyString_Join __Pyx_PyBytes_Join
#define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v))
#else
#define __Pyx_PyString_Join PyUnicode_Join
#define __Pyx_PyBaseString_Join PyUnicode_Join
#endif
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION < 3
    #define __Pyx_PyBytes_Join _PyString_Join
    #else
    #define __Pyx_PyBytes_Join _PyBytes_Join
    #endif
#else
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values);
#endif

static CYTHON_INLINE int __Pyx_IterFinish(void);

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback, int nogil);

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_SubtractCObj(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_SubtractCObj(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyFloat_EqObjC(PyObject *op1, PyObject *op2, double floatval, int inplace);
#else
#define __Pyx_PyFloat_EqObjC(op1, op2, floatval, inplace)\
    PyObject_RichCompare(op1, op2, Py_EQ)
    #endif

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyFloat_DivideCObj(PyObject *op1, PyObject *op2, double floatval, int inplace);
#else
#define __Pyx_PyFloat_DivideCObj(op1, op2, floatval, inplace)\
    ((inplace ? __Pyx_PyNumber_InPlaceDivide(op1, op2) : __Pyx_PyNumber_Divide(op1, op2)))
    #endif

static double __Pyx__PyObject_AsDouble(PyObject* obj);
#if CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyObject_AsDouble(obj)\
(likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) :\
 likely(PyInt_CheckExact(obj)) ?\
 PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj))
#else
#define __Pyx_PyObject_AsDouble(obj)\
((likely(PyFloat_CheckExact(obj))) ?\
 PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_SubtractObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
#endif

static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact);

static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d);

typedef struct {
    PyObject *type;
    PyObject **method_name;
    PyCFunction func;   // set on first access (direct C function pointer)
    PyObject *method;   // set on first access (fallback)
    int flag;
} __Pyx_CachedCFunction;

static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_CallUnboundCMethod0(cfunc, self)\
    ((likely((cfunc)->func)) ?\
        (likely((cfunc)->flag == METH_NOARGS) ?  (*((cfunc)->func))(self, NULL) :\
         (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ?  ((*(PyCFunctionWithKeywords)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\
             ((cfunc)->flag == METH_VARARGS ?  (*((cfunc)->func))(self, __pyx_empty_tuple) : __Pyx__CallUnboundCMethod0(cfunc, self)))) :\
        __Pyx__CallUnboundCMethod0(cfunc, self))
#else
#define __Pyx_CallUnboundCMethod0(cfunc, self)  __Pyx__CallUnboundCMethod0(cfunc, self)
#endif

static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d);

#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            PyObject* args = PyTuple_Pack(1, key);
            if (likely(args))
                PyErr_SetObject(PyExc_KeyError, args);
            Py_XDECREF(args);
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#else
    #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#endif

static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d);

static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value);

#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL)
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_setattro))
        return tp->tp_setattro(obj, attr_name, value);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_setattr))
        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
#endif
    return PyObject_SetAttr(obj, attr_name, value);
}
#else
#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);

static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
        PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
        int has_cstart, int has_cstop, int wraparound);

static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

static int __Pyx_SetVtable(PyObject *dict, void *vtable);

static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name);

typedef struct {
    int code_line;
    PyCodeObject* code_object;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

static PyObject* __Pyx_Globals(void);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value);

static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

static CYTHON_INLINE Py_intptr_t __Pyx_PyInt_As_Py_intptr_t(PyObject *);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);

#include "descrobject.h"
static PyObject* __Pyx_Method_ClassMethod(PyObject *method);

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #define __Pyx_CREAL(z) ((z).real())
    #define __Pyx_CIMAG(z) ((z).imag())
  #else
    #define __Pyx_CREAL(z) (__real__(z))
    #define __Pyx_CIMAG(z) (__imag__(z))
  #endif
#else
    #define __Pyx_CREAL(z) ((z).real)
    #define __Pyx_CIMAG(z) ((z).imag)
#endif
#if (defined(_WIN32) || defined(__clang__)) && defined(__cplusplus) && CYTHON_CCOMPLEX
    #define __Pyx_SET_CREAL(z,x) ((z).real(x))
    #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
#else
    #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
    #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
#endif

static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);

#if CYTHON_CCOMPLEX
    #define __Pyx_c_eqf(a, b)   ((a)==(b))
    #define __Pyx_c_sumf(a, b)  ((a)+(b))
    #define __Pyx_c_difff(a, b) ((a)-(b))
    #define __Pyx_c_prodf(a, b) ((a)*(b))
    #define __Pyx_c_quotf(a, b) ((a)/(b))
    #define __Pyx_c_negf(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zerof(z) ((z)==(float)0)
    #define __Pyx_c_conjf(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_absf(z)     (::std::abs(z))
        #define __Pyx_c_powf(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zerof(z) ((z)==0)
    #define __Pyx_c_conjf(z)    (conjf(z))
    #if 1
        #define __Pyx_c_absf(z)     (cabsf(z))
        #define __Pyx_c_powf(a, b)  (cpowf(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex);
    static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex);
    #if 1
        static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex);
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex);
    #endif
#endif

static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);

#if CYTHON_CCOMPLEX
    #define __Pyx_c_eq(a, b)   ((a)==(b))
    #define __Pyx_c_sum(a, b)  ((a)+(b))
    #define __Pyx_c_diff(a, b) ((a)-(b))
    #define __Pyx_c_prod(a, b) ((a)*(b))
    #define __Pyx_c_quot(a, b) ((a)/(b))
    #define __Pyx_c_neg(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zero(z) ((z)==(double)0)
    #define __Pyx_c_conj(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_abs(z)     (::std::abs(z))
        #define __Pyx_c_pow(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zero(z) ((z)==0)
    #define __Pyx_c_conj(z)    (conj(z))
    #if 1
        #define __Pyx_c_abs(z)     (cabs(z))
        #define __Pyx_c_pow(a, b)  (cpow(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex);
    static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex);
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex);
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex);
    #endif
#endif

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value);

static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);

typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyObject *);
typedef struct {
    PyObject_HEAD
    __pyx_coroutine_body_t body;
    PyObject *closure;
    PyObject *exc_type;
    PyObject *exc_value;
    PyObject *exc_traceback;
    PyObject *gi_weakreflist;
    PyObject *classobj;
    PyObject *yieldfrom;
    PyObject *gi_name;
    PyObject *gi_qualname;
    int resume_label;
    char is_running;
} __pyx_CoroutineObject;
static __pyx_CoroutineObject *__Pyx__Coroutine_New(PyTypeObject *type, __pyx_coroutine_body_t body,
                                                   PyObject *closure, PyObject *name, PyObject *qualname);
static int __Pyx_Coroutine_clear(PyObject *self);
#if 1 || PY_VERSION_HEX < 0x030300B0
static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue);
#else
#define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue)
#endif

static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);

static int __Pyx_patch_abc(void);

#define __Pyx_Generator_USED
static PyTypeObject *__pyx_GeneratorType = 0;
#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
#define __Pyx_Generator_New(body, closure, name, qualname)\
    __Pyx__Coroutine_New(__pyx_GeneratorType, body, closure, name, qualname)
static PyObject *__Pyx_Generator_Next(PyObject *self);
static int __pyx_Generator_init(void);

static int __Pyx_check_binary_version(void);

#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

static PyObject *__Pyx_ImportModule(const char *name);

static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);

static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);

static double __pyx_f_11pomegranate_13distributions_12Distribution__log_probability(CYTHON_UNUSED struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, CYTHON_UNUSED double __pyx_v_symbol); /* proto*/
static double __pyx_f_11pomegranate_13distributions_12Distribution__mv_log_probability(CYTHON_UNUSED struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, CYTHON_UNUSED double *__pyx_v_symbol); /* proto*/
static void __pyx_f_11pomegranate_13distributions_12Distribution__summarize(CYTHON_UNUSED struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, CYTHON_UNUSED double *__pyx_v_items, CYTHON_UNUSED double *__pyx_v_weights, CYTHON_UNUSED __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n); /* proto*/
static double __pyx_f_11pomegranate_13distributions_19UniformDistribution__log_probability(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self, double __pyx_v_symbol); /* proto*/
static void __pyx_f_11pomegranate_13distributions_19UniformDistribution__summarize(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self, double *__pyx_v_items, CYTHON_UNUSED double *__pyx_v_weights, __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n); /* proto*/
static double __pyx_f_11pomegranate_13distributions_18NormalDistribution__log_probability(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self, double __pyx_v_symbol); /* proto*/
static void __pyx_f_11pomegranate_13distributions_18NormalDistribution__summarize(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self, double *__pyx_v_items, double *__pyx_v_weights, __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n); /* proto*/
static double __pyx_f_11pomegranate_13distributions_21LogNormalDistribution__log_probability(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self, double __pyx_v_symbol); /* proto*/
static void __pyx_f_11pomegranate_13distributions_21LogNormalDistribution__summarize(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self, double *__pyx_v_items, double *__pyx_v_weights, __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n); /* proto*/
static double __pyx_f_11pomegranate_13distributions_23ExponentialDistribution__log_probability(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self, double __pyx_v_symbol); /* proto*/
static void __pyx_f_11pomegranate_13distributions_23ExponentialDistribution__summarize(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self, double *__pyx_v_items, double *__pyx_v_weights, __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n); /* proto*/
static double __pyx_f_11pomegranate_13distributions_16BetaDistribution__log_probability(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self, double __pyx_v_symbol); /* proto*/
static void __pyx_f_11pomegranate_13distributions_16BetaDistribution__summarize(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self, double *__pyx_v_items, double *__pyx_v_weights, __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n); /* proto*/
static double __pyx_f_11pomegranate_13distributions_17GammaDistribution__log_probability(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *__pyx_v_self, double __pyx_v_symbol); /* proto*/
static double __pyx_f_11pomegranate_13distributions_20DiscreteDistribution___log_probability(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_symbol); /* proto*/
static double __pyx_f_11pomegranate_13distributions_20DiscreteDistribution__log_probability(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, double __pyx_v_symbol); /* proto*/
static void __pyx_f_11pomegranate_13distributions_20DiscreteDistribution__summarize(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, double *__pyx_v_items, double *__pyx_v_weights, __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n); /* proto*/
static double __pyx_f_11pomegranate_13distributions_21GaussianKernelDensity__log_probability(struct __pyx_obj_11pomegranate_13distributions_GaussianKernelDensity *__pyx_v_self, double __pyx_v_symbol); /* proto*/
static double __pyx_f_11pomegranate_13distributions_20UniformKernelDensity__log_probability(struct __pyx_obj_11pomegranate_13distributions_UniformKernelDensity *__pyx_v_self, double __pyx_v_symbol); /* proto*/
static double __pyx_f_11pomegranate_13distributions_21TriangleKernelDensity__log_probability(struct __pyx_obj_11pomegranate_13distributions_TriangleKernelDensity *__pyx_v_self, double __pyx_v_symbol); /* proto*/
static double __pyx_f_11pomegranate_13distributions_19MixtureDistribution__log_probability(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self, double __pyx_v_symbol); /* proto*/
static double __pyx_f_11pomegranate_13distributions_33IndependentComponentsDistribution__mv_log_probability(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self, double *__pyx_v_symbol); /* proto*/
static void __pyx_f_11pomegranate_13distributions_33IndependentComponentsDistribution__summarize(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self, CYTHON_UNUSED double *__pyx_v_items, CYTHON_UNUSED double *__pyx_v_weights, __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n); /* proto*/
static double __pyx_f_11pomegranate_13distributions_32MultivariateGaussianDistribution__mv_log_probability(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, double *__pyx_v_symbol); /* proto*/
static void __pyx_f_11pomegranate_13distributions_32MultivariateGaussianDistribution__summarize(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, double *__pyx_v_items, double *__pyx_v_weights, __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n); /* proto*/
static void __pyx_f_11pomegranate_13distributions_32MultivariateGaussianDistribution__from_summaries(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, double __pyx_v_inertia); /* proto*/

/* Module declarations from 'cpython.buffer' */

/* Module declarations from 'libc.string' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.type' */
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;

/* Module declarations from 'cpython' */

/* Module declarations from 'cpython.object' */

/* Module declarations from 'cpython.ref' */

/* Module declarations from 'libc.stdlib' */

/* Module declarations from 'numpy' */

/* Module declarations from 'numpy' */
static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/

/* Module declarations from 'libc.math' */

/* Module declarations from 'pomegranate.utils' */
static CYTHON_INLINE double (*__pyx_f_11pomegranate_5utils__log)(double); /*proto*/
static CYTHON_INLINE double (*__pyx_f_11pomegranate_5utils_pair_lse)(double, double); /*proto*/

/* Module declarations from 'pomegranate.distributions' */
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_Distribution = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_UniformDistribution = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_NormalDistribution = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_LogNormalDistribution = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_ExponentialDistribution = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_BetaDistribution = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_GammaDistribution = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_DiscreteDistribution = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_LambdaDistribution = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_KernelDensity = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_GaussianKernelDensity = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_UniformKernelDensity = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_TriangleKernelDensity = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_MixtureDistribution = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_MultivariateDistribution = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_IndependentComponentsDistribution = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_MultivariateGaussianDistribution = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_ConditionalProbabilityTable = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions_JointProbabilityTable = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct____str__ = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_1_genexpr = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_2_keys = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_3_genexpr = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_4_joint = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_5_genexpr = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_6___str__ = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_7_genexpr = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_8_keys = 0;
static PyTypeObject *__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_9_genexpr = 0;
#define __Pyx_MODULE_NAME "pomegranate.distributions"
int __pyx_module_is_main_pomegranate__distributions = 0;

/* Implementation of 'pomegranate.distributions' */
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_zip;
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_SyntaxError;
static PyObject *__pyx_builtin_eval;
static PyObject *__pyx_builtin_map;
static PyObject *__pyx_builtin_round;
static PyObject *__pyx_builtin_sum;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_RuntimeError;
static char __pyx_k_[] = "*";
static char __pyx_k_B[] = "B";
static char __pyx_k_H[] = "H";
static char __pyx_k_I[] = "I";
static char __pyx_k_L[] = "L";
static char __pyx_k_O[] = "O";
static char __pyx_k_Q[] = "Q";
static char __pyx_k_b[] = "b";
static char __pyx_k_d[] = "d";
static char __pyx_k_f[] = "f";
static char __pyx_k_g[] = "g";
static char __pyx_k_h[] = "h";
static char __pyx_k_i[] = "i";
static char __pyx_k_l[] = "l";
static char __pyx_k_n[] = "n";
static char __pyx_k_p[] = "p";
static char __pyx_k_q[] = "q";
static char __pyx_k_s[] = "s";
static char __pyx_k_Zd[] = "Zd";
static char __pyx_k_Zf[] = "Zf";
static char __pyx_k_Zg[] = "Zg";
static char __pyx_k__2[] = ",";
static char __pyx_k__3[] = " : ";
static char __pyx_k__5[] = " ";
static char __pyx_k_it[] = "it";
static char __pyx_k_mu[] = "mu";
static char __pyx_k__30[] = "\t";
static char __pyx_k__31[] = "\n";
static char __pyx_k_cls[] = "cls";
static char __pyx_k_det[] = "det";
static char __pyx_k_dot[] = "dot";
static char __pyx_k_end[] = "end";
static char __pyx_k_exp[] = "exp";
static char __pyx_k_get[] = "get";
static char __pyx_k_inf[] = "inf";
static char __pyx_k_inv[] = "inv";
static char __pyx_k_log[] = "log";
static char __pyx_k_map[] = "map";
static char __pyx_k_std[] = "std";
static char __pyx_k_sum[] = "sum";
static char __pyx_k_sys[] = "sys";
static char __pyx_k_wrt[] = "wrt";
static char __pyx_k_zip[] = "zip";
static char __pyx_k_args[] = "args";
static char __pyx_k_axis[] = "axis";
static char __pyx_k_beta[] = "beta";
static char __pyx_k_dist[] = "dist";
static char __pyx_k_eval[] = "eval";
static char __pyx_k_hist[] = "hist";
static char __pyx_k_izip[] = "izip";
static char __pyx_k_join[] = "join";
static char __pyx_k_json[] = "json";
static char __pyx_k_keys[] = "keys";
static char __pyx_k_main[] = "__main__";
static char __pyx_k_mean[] = "mean";
static char __pyx_k_name[] = "name";
static char __pyx_k_ones[] = "ones";
static char __pyx_k_rate[] = "rate";
static char __pyx_k_send[] = "send";
static char __pyx_k_test[] = "__test__";
static char __pyx_k_alpha[] = "alpha";
static char __pyx_k_array[] = "array";
static char __pyx_k_class[] = "__class__";
static char __pyx_k_close[] = "close";
static char __pyx_k_dtype[] = "dtype";
static char __pyx_k_dumps[] = "dumps";
static char __pyx_k_gauss[] = "gauss";
static char __pyx_k_index[] = "index";
static char __pyx_k_items[] = "items";
static char __pyx_k_joint[] = "joint";
static char __pyx_k_loads[] = "loads";
static char __pyx_k_means[] = "means";
static char __pyx_k_numpy[] = "numpy";
static char __pyx_k_range[] = "range";
static char __pyx_k_round[] = "round";
static char __pyx_k_scipy[] = "scipy";
static char __pyx_k_shape[] = "shape";
static char __pyx_k_sigma[] = "sigma";
static char __pyx_k_start[] = "start";
static char __pyx_k_table[] = "table";
static char __pyx_k_throw[] = "throw";
static char __pyx_k_train[] = "train";
static char __pyx_k_value[] = "value";
static char __pyx_k_zeros[] = "zeros";
static char __pyx_k_append[] = "append";
static char __pyx_k_astype[] = "astype";
static char __pyx_k_choice[] = "choice";
static char __pyx_k_encode[] = "encode";
static char __pyx_k_format[] = "format";
static char __pyx_k_frozen[] = "frozen";
static char __pyx_k_import[] = "__import__";
static char __pyx_k_indent[] = "indent";
static char __pyx_k_linalg[] = "linalg";
static char __pyx_k_object[] = "object_";
static char __pyx_k_points[] = "points";
static char __pyx_k_random[] = "random";
static char __pyx_k_sample[] = "sample";
static char __pyx_k_tolist[] = "tolist";
static char __pyx_k_values[] = "values";
static char __pyx_k_xrange[] = "xrange";
static char __pyx_k_asarray[] = "asarray";
static char __pyx_k_average[] = "average";
static char __pyx_k_class_2[] = "class";
static char __pyx_k_epsilon[] = "epsilon";
static char __pyx_k_float64[] = "float64";
static char __pyx_k_genexpr[] = "genexpr";
static char __pyx_k_inertia[] = "inertia";
static char __pyx_k_min_std[] = "min_std";
static char __pyx_k_parents[] = "parents";
static char __pyx_k_special[] = "special";
static char __pyx_k_to_json[] = "to_json";
static char __pyx_k_uniform[] = "uniform";
static char __pyx_k_weights[] = "weights";
static char __pyx_k_frozen_2[] = "{}( {}, frozen={} )";
static char __pyx_k_marginal[] = "marginal";
static char __pyx_k_bandwidth[] = "bandwidth";
static char __pyx_k_enumerate[] = "enumerate";
static char __pyx_k_from_json[] = "from_json";
static char __pyx_k_itertools[] = "itertools";
static char __pyx_k_lognormal[] = "lognormal";
static char __pyx_k_neighbors[] = "neighbors";
static char __pyx_k_ones_like[] = "ones_like";
static char __pyx_k_polygamma[] = "polygamma";
static char __pyx_k_summarize[] = "summarize";
static char __pyx_k_to_return[] = "to_return";
static char __pyx_k_ValueError[] = "ValueError";
static char __pyx_k_characters[] = "characters";
static char __pyx_k_covariance[] = "covariance";
static char __pyx_k_parameters[] = "parameters";
static char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static char __pyx_k_separators[] = "separators";
static char __pyx_k_triangular[] = "triangular";
static char __pyx_k_weight_set[] = "weight_set";
static char __pyx_k_zeros_like[] = "zeros_like";
static char __pyx_k_OrderedDict[] = "OrderedDict";
static char __pyx_k_SyntaxError[] = "SyntaxError";
static char __pyx_k_betavariate[] = "betavariate";
static char __pyx_k_collections[] = "collections";
static char __pyx_k_concatenate[] = "concatenate";
static char __pyx_k_expovariate[] = "expovariate";
static char __pyx_k_from_sample[] = "from_sample";
static char __pyx_k_pseudocount[] = "pseudocount";
static char __pyx_k_Distribution[] = "Distribution";
static char __pyx_k_RuntimeError[] = "RuntimeError";
static char __pyx_k_gammavariate[] = "gammavariate";
static char __pyx_k_lambda_funct[] = "lambda_funct";
static char __pyx_k_version_info[] = "version_info";
static char __pyx_k_KernelDensity[] = "KernelDensity";
static char __pyx_k_distributions[] = "distributions";
static char __pyx_k_normalvariate[] = "normalvariate";
static char __pyx_k_scipy_special[] = "scipy.special";
static char __pyx_k_from_summaries[] = "from_summaries";
static char __pyx_k_iteration_limit[] = "iteration_limit";
static char __pyx_k_log_probability[] = "log_probability";
static char __pyx_k_neighbor_values[] = "neighbor_values";
static char __pyx_k_BetaDistribution[] = "BetaDistribution";
static char __pyx_k_GammaDistribution[] = "GammaDistribution";
static char __pyx_k_matplotlib_pyplot[] = "matplotlib.pyplot";
static char __pyx_k_LambdaDistribution[] = "LambdaDistribution";
static char __pyx_k_NormalDistribution[] = "NormalDistribution";
static char __pyx_k_MixtureDistribution[] = "MixtureDistribution";
static char __pyx_k_NotImplementedError[] = "NotImplementedError";
static char __pyx_k_UniformDistribution[] = "UniformDistribution";
static char __pyx_k_keys_locals_genexpr[] = "keys.<locals>.genexpr";
static char __pyx_k_multivariate_normal[] = "multivariate_normal";
static char __pyx_k_DiscreteDistribution[] = "DiscreteDistribution";
static char __pyx_k_UniformKernelDensity[] = "UniformKernelDensity";
static char __pyx_k_joint_locals_genexpr[] = "joint.<locals>.genexpr";
static char __pyx_k_str___locals_genexpr[] = "__str__.<locals>.genexpr";
static char __pyx_k_GaussianKernelDensity[] = "GaussianKernelDensity";
static char __pyx_k_JointProbabilityTable[] = "JointProbabilityTable";
static char __pyx_k_LogNormalDistribution[] = "LogNormalDistribution";
static char __pyx_k_TriangleKernelDensity[] = "TriangleKernelDensity";
static char __pyx_k_ExponentialDistribution[] = "ExponentialDistribution";
static char __pyx_k_pomegranate_distributions[] = "pomegranate.distributions";
static char __pyx_k_ConditionalProbabilityTable[] = "ConditionalProbabilityTable";
static char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous";
static char __pyx_k_mu_shape_is_while_cov_shape_is[] = "mu shape is {} while cov shape is {}";
static char __pyx_k_home_jmschr_Desktop_pomegranate[] = "/home/jmschr/Desktop/pomegranate/pomegranate/distributions.pyx";
static char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)";
static char __pyx_k_Distribution_object_attempting_t[] = "Distribution object attempting to read invalid object.";
static char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd";
static char __pyx_k_IndependentComponentsDistributio[] = "IndependentComponentsDistribution";
static char __pyx_k_MultivariateGaussianDistribution[] = "MultivariateGaussianDistribution";
static char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported";
static char __pyx_k_cov_is_not_a_square_matrix_dimen[] = "cov is not a square matrix, dimensions are ({}, {})";
static char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous";
static char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short.";
static PyObject *__pyx_n_s_;
static PyObject *__pyx_n_s_BetaDistribution;
static PyObject *__pyx_n_s_ConditionalProbabilityTable;
static PyObject *__pyx_n_s_DiscreteDistribution;
static PyObject *__pyx_n_s_Distribution;
static PyObject *__pyx_kp_s_Distribution_object_attempting_t;
static PyObject *__pyx_n_s_ExponentialDistribution;
static PyObject *__pyx_kp_u_Format_string_allocated_too_shor;
static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2;
static PyObject *__pyx_n_s_GammaDistribution;
static PyObject *__pyx_n_s_GaussianKernelDensity;
static PyObject *__pyx_n_s_IndependentComponentsDistributio;
static PyObject *__pyx_n_s_JointProbabilityTable;
static PyObject *__pyx_n_s_KernelDensity;
static PyObject *__pyx_n_s_LambdaDistribution;
static PyObject *__pyx_n_s_LogNormalDistribution;
static PyObject *__pyx_n_s_MixtureDistribution;
static PyObject *__pyx_n_s_MultivariateGaussianDistribution;
static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor;
static PyObject *__pyx_n_s_NormalDistribution;
static PyObject *__pyx_n_s_NotImplementedError;
static PyObject *__pyx_n_s_OrderedDict;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_n_s_SyntaxError;
static PyObject *__pyx_n_s_TriangleKernelDensity;
static PyObject *__pyx_n_s_UniformDistribution;
static PyObject *__pyx_n_s_UniformKernelDensity;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_kp_s__2;
static PyObject *__pyx_kp_s__3;
static PyObject *__pyx_kp_s__30;
static PyObject *__pyx_kp_s__31;
static PyObject *__pyx_kp_s__5;
static PyObject *__pyx_n_s_alpha;
static PyObject *__pyx_n_s_append;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_array;
static PyObject *__pyx_n_s_asarray;
static PyObject *__pyx_n_s_astype;
static PyObject *__pyx_n_s_average;
static PyObject *__pyx_n_s_axis;
static PyObject *__pyx_n_s_bandwidth;
static PyObject *__pyx_n_s_beta;
static PyObject *__pyx_n_s_betavariate;
static PyObject *__pyx_n_s_characters;
static PyObject *__pyx_n_s_choice;
static PyObject *__pyx_n_s_class;
static PyObject *__pyx_n_s_class_2;
static PyObject *__pyx_n_s_close;
static PyObject *__pyx_n_s_cls;
static PyObject *__pyx_n_s_collections;
static PyObject *__pyx_n_s_concatenate;
static PyObject *__pyx_kp_s_cov_is_not_a_square_matrix_dimen;
static PyObject *__pyx_n_s_covariance;
static PyObject *__pyx_n_s_d;
static PyObject *__pyx_n_s_det;
static PyObject *__pyx_n_s_dist;
static PyObject *__pyx_n_s_distributions;
static PyObject *__pyx_n_s_dot;
static PyObject *__pyx_n_s_dtype;
static PyObject *__pyx_n_s_dumps;
static PyObject *__pyx_n_s_encode;
static PyObject *__pyx_n_s_end;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_n_s_epsilon;
static PyObject *__pyx_n_s_eval;
static PyObject *__pyx_n_s_exp;
static PyObject *__pyx_n_s_expovariate;
static PyObject *__pyx_n_s_float64;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_n_s_from_json;
static PyObject *__pyx_n_s_from_sample;
static PyObject *__pyx_n_s_from_summaries;
static PyObject *__pyx_n_s_frozen;
static PyObject *__pyx_kp_s_frozen_2;
static PyObject *__pyx_n_s_gammavariate;
static PyObject *__pyx_n_s_gauss;
static PyObject *__pyx_n_s_genexpr;
static PyObject *__pyx_n_s_get;
static PyObject *__pyx_n_s_hist;
static PyObject *__pyx_kp_s_home_jmschr_Desktop_pomegranate;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_indent;
static PyObject *__pyx_n_s_index;
static PyObject *__pyx_n_s_inertia;
static PyObject *__pyx_n_s_inf;
static PyObject *__pyx_n_s_inv;
static PyObject *__pyx_n_s_it;
static PyObject *__pyx_n_s_items;
static PyObject *__pyx_n_s_iteration_limit;
static PyObject *__pyx_n_s_itertools;
static PyObject *__pyx_n_s_izip;
static PyObject *__pyx_n_s_join;
static PyObject *__pyx_n_s_joint;
static PyObject *__pyx_n_s_joint_locals_genexpr;
static PyObject *__pyx_n_s_json;
static PyObject *__pyx_n_s_keys;
static PyObject *__pyx_n_s_keys_locals_genexpr;
static PyObject *__pyx_n_s_lambda_funct;
static PyObject *__pyx_n_s_linalg;
static PyObject *__pyx_n_s_loads;
static PyObject *__pyx_n_s_log;
static PyObject *__pyx_n_s_log_probability;
static PyObject *__pyx_n_s_lognormal;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_map;
static PyObject *__pyx_n_s_marginal;
static PyObject *__pyx_n_s_matplotlib_pyplot;
static PyObject *__pyx_n_s_mean;
static PyObject *__pyx_n_s_means;
static PyObject *__pyx_n_s_min_std;
static PyObject *__pyx_n_s_mu;
static PyObject *__pyx_kp_s_mu_shape_is_while_cov_shape_is;
static PyObject *__pyx_n_s_multivariate_normal;
static PyObject *__pyx_n_s_n;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous;
static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou;
static PyObject *__pyx_n_s_neighbor_values;
static PyObject *__pyx_n_s_neighbors;
static PyObject *__pyx_n_s_normalvariate;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_n_s_object;
static PyObject *__pyx_n_s_ones;
static PyObject *__pyx_n_s_ones_like;
static PyObject *__pyx_n_s_p;
static PyObject *__pyx_n_s_parameters;
static PyObject *__pyx_n_s_parents;
static PyObject *__pyx_n_s_points;
static PyObject *__pyx_n_s_polygamma;
static PyObject *__pyx_n_s_pomegranate_distributions;
static PyObject *__pyx_n_s_pseudocount;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_random;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_rate;
static PyObject *__pyx_n_s_round;
static PyObject *__pyx_n_s_s;
static PyObject *__pyx_n_s_sample;
static PyObject *__pyx_n_s_scipy;
static PyObject *__pyx_n_s_scipy_special;
static PyObject *__pyx_n_s_send;
static PyObject *__pyx_n_s_separators;
static PyObject *__pyx_n_s_shape;
static PyObject *__pyx_n_s_sigma;
static PyObject *__pyx_n_s_special;
static PyObject *__pyx_n_s_start;
static PyObject *__pyx_n_s_std;
static PyObject *__pyx_n_s_str___locals_genexpr;
static PyObject *__pyx_n_s_sum;
static PyObject *__pyx_n_s_summarize;
static PyObject *__pyx_n_s_sys;
static PyObject *__pyx_n_s_table;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_throw;
static PyObject *__pyx_n_s_to_json;
static PyObject *__pyx_n_s_to_return;
static PyObject *__pyx_n_s_tolist;
static PyObject *__pyx_n_s_train;
static PyObject *__pyx_n_s_triangular;
static PyObject *__pyx_n_s_uniform;
static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd;
static PyObject *__pyx_n_s_value;
static PyObject *__pyx_n_s_values;
static PyObject *__pyx_n_s_version_info;
static PyObject *__pyx_n_s_weight_set;
static PyObject *__pyx_n_s_weights;
static PyObject *__pyx_n_s_wrt;
static PyObject *__pyx_n_s_xrange;
static PyObject *__pyx_n_s_zeros;
static PyObject *__pyx_n_s_zeros_like;
static PyObject *__pyx_n_s_zip;
static PyObject *__pyx_pf_11pomegranate_13distributions_log(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_2weight_set(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights); /* proto */
static int __pyx_pf_11pomegranate_13distributions_12Distribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_2__str__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_4__repr__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_6marginal(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_8copy(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_10freeze(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_12thaw(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_14log_probability(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, double __pyx_v_symbol); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_16sample(CYTHON_UNUSED struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_18fit(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_20train(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_22from_sample(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_items, CYTHON_UNUSED PyObject *__pyx_v_weights, CYTHON_UNUSED PyObject *__pyx_v_inertia); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_24summarize(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_26from_summaries(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, PyObject *__pyx_v_inertia); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_28plot(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, PyObject *__pyx_v_n, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_30to_json(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_32from_json(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_s); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_4name___get__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_12Distribution_4name_2__set__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_11pomegranate_13distributions_12Distribution_4name_4__del__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_9summaries___get__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_12Distribution_9summaries_2__set__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_11pomegranate_13distributions_12Distribution_9summaries_4__del__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_6frozen___get__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_12Distribution_6frozen_2__set__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_19UniformDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_19UniformDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self, PyObject *__pyx_v_parameters); /* proto */
static int __pyx_pf_11pomegranate_13distributions_19UniformDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self, double __pyx_v_start, double __pyx_v_end, int __pyx_v_frozen); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_19UniformDistribution_2sample(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_19UniformDistribution_4from_sample(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_19UniformDistribution_6summarize(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self, PyObject *__pyx_v_items, CYTHON_UNUSED PyObject *__pyx_v_weights); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_19UniformDistribution_8from_summaries(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self, PyObject *__pyx_v_inertia); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_18NormalDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_18NormalDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self, PyObject *__pyx_v_parameters); /* proto */
static int __pyx_pf_11pomegranate_13distributions_18NormalDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self, double __pyx_v_mean, double __pyx_v_std, int __pyx_v_frozen); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_18NormalDistribution_2sample(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_18NormalDistribution_4from_sample(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia, PyObject *__pyx_v_min_std); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_18NormalDistribution_6summarize(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_18NormalDistribution_8from_summaries(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self, PyObject *__pyx_v_inertia, PyObject *__pyx_v_min_std); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self, PyObject *__pyx_v_parameters); /* proto */
static int __pyx_pf_11pomegranate_13distributions_21LogNormalDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self, double __pyx_v_mu, double __pyx_v_sigma, PyObject *__pyx_v_frozen); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_2sample(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_4from_sample(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia, PyObject *__pyx_v_min_std); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_6summarize(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_8from_summaries(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self, PyObject *__pyx_v_inertia, PyObject *__pyx_v_min_std); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self, PyObject *__pyx_v_parameters); /* proto */
static int __pyx_pf_11pomegranate_13distributions_23ExponentialDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self, double __pyx_v_rate, int __pyx_v_frozen); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_2sample(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_4from_sample(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_6summarize(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_8from_summaries(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_inertia); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_16BetaDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_16BetaDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self, PyObject *__pyx_v_parameters); /* proto */
static int __pyx_pf_11pomegranate_13distributions_16BetaDistribution___init__(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self, PyObject *__pyx_v_alpha, PyObject *__pyx_v_beta, PyObject *__pyx_v_frozen); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_16BetaDistribution_2sample(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_16BetaDistribution_4from_sample(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_16BetaDistribution_6summarize(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_16BetaDistribution_8from_summaries(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self, PyObject *__pyx_v_inertia); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_17GammaDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_17GammaDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *__pyx_v_self, PyObject *__pyx_v_parameters); /* proto */
static int __pyx_pf_11pomegranate_13distributions_17GammaDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *__pyx_v_self, double __pyx_v_alpha, double __pyx_v_beta, int __pyx_v_frozen); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_17GammaDistribution_2sample(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_17GammaDistribution_4from_sample(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia, PyObject *__pyx_v_epsilon, PyObject *__pyx_v_iteration_limit); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_17GammaDistribution_6summarize(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_17GammaDistribution_8from_summaries(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *__pyx_v_self, PyObject *__pyx_v_inertia, PyObject *__pyx_v_epsilon, PyObject *__pyx_v_iteration_limit); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_parameters); /* proto */
static int __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_characters, int __pyx_v_frozen); /* proto */
static void __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_2__dealloc__(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_4__len__(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_6__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_8equals(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_10clamp(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_12keys(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_14items(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_16values(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_18mle(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_20encode(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_encoded_keys); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_22log_probability(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_symbol); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_24sample(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_26from_sample(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_28summarize(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_30from_summaries(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_inertia); /* proto */
static int __pyx_pf_11pomegranate_13distributions_18LambdaDistribution___init__(struct __pyx_obj_11pomegranate_13distributions_LambdaDistribution *__pyx_v_self, PyObject *__pyx_v_lambda_funct, PyObject *__pyx_v_frozen); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_18LambdaDistribution_2log_probability(struct __pyx_obj_11pomegranate_13distributions_LambdaDistribution *__pyx_v_self, PyObject *__pyx_v_symbol); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_13KernelDensity_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_KernelDensity *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_13KernelDensity_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_KernelDensity *__pyx_v_self, PyObject *__pyx_v_parameters); /* proto */
static int __pyx_pf_11pomegranate_13distributions_13KernelDensity___cinit__(struct __pyx_obj_11pomegranate_13distributions_KernelDensity *__pyx_v_self, PyObject *__pyx_v_points, PyObject *__pyx_v_bandwidth, PyObject *__pyx_v_weights, PyObject *__pyx_v_frozen); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_13KernelDensity_2from_sample(struct __pyx_obj_11pomegranate_13distributions_KernelDensity *__pyx_v_self, PyObject *__pyx_v_points, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia); /* proto */
static int __pyx_pf_11pomegranate_13distributions_21GaussianKernelDensity___cinit__(struct __pyx_obj_11pomegranate_13distributions_GaussianKernelDensity *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_points, CYTHON_UNUSED PyObject *__pyx_v_bandwidth, CYTHON_UNUSED PyObject *__pyx_v_weights, CYTHON_UNUSED PyObject *__pyx_v_frozen); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_21GaussianKernelDensity_2sample(struct __pyx_obj_11pomegranate_13distributions_GaussianKernelDensity *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_20UniformKernelDensity___cinit__(struct __pyx_obj_11pomegranate_13distributions_UniformKernelDensity *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_points, CYTHON_UNUSED PyObject *__pyx_v_bandwidth, CYTHON_UNUSED PyObject *__pyx_v_weights, CYTHON_UNUSED PyObject *__pyx_v_frozen); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_20UniformKernelDensity_2sample(struct __pyx_obj_11pomegranate_13distributions_UniformKernelDensity *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_21TriangleKernelDensity___cinit__(struct __pyx_obj_11pomegranate_13distributions_TriangleKernelDensity *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_points, CYTHON_UNUSED PyObject *__pyx_v_bandwidth, CYTHON_UNUSED PyObject *__pyx_v_weights, CYTHON_UNUSED PyObject *__pyx_v_frozen); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_21TriangleKernelDensity_2sample(struct __pyx_obj_11pomegranate_13distributions_TriangleKernelDensity *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_19MixtureDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_19MixtureDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self, PyObject *__pyx_v_parameters); /* proto */
static int __pyx_pf_11pomegranate_13distributions_19MixtureDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self, PyObject *__pyx_v_distributions, PyObject *__pyx_v_weights, PyObject *__pyx_v_frozen); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_19MixtureDistribution_2sample(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_19MixtureDistribution_4from_sample(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_19MixtureDistribution_6summarize(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_19MixtureDistribution_8from_summaries(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self, PyObject *__pyx_v_inertia); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_19MixtureDistribution_10to_json(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_24MultivariateDistribution_1d___get__(struct __pyx_obj_11pomegranate_13distributions_MultivariateDistribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_24MultivariateDistribution_1d_2__set__(struct __pyx_obj_11pomegranate_13distributions_MultivariateDistribution *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self, PyObject *__pyx_v_parameters); /* proto */
static int __pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self, PyObject *__pyx_v_distributions, PyObject *__pyx_v_weights, PyObject *__pyx_v_frozen); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_2log_probability(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self, PyObject *__pyx_v_symbol); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_4sample(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_6from_sample(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_8summarize(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_10from_summaries(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self, PyObject *__pyx_v_inertia); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_12to_json(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, PyObject *__pyx_v_parameters); /* proto */
static int __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, PyObject *__pyx_v_means, PyObject *__pyx_v_covariance, PyObject *__pyx_v_frozen); /* proto */
static void __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_2__dealloc__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_4log_probability(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, PyObject *__pyx_v_symbol); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_6sample(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_8from_sample(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_10summarize(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_12from_summaries(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, double __pyx_v_inertia); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu___get__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu_2__set__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu_4__del__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov___get__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov_2__set__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov_4__del__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray___get__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray_2__set__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray_4__del__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable___init__(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self, PyObject *__pyx_v_table, PyObject *__pyx_v_parents, PyObject *__pyx_v_keys, CYTHON_UNUSED PyObject *__pyx_v_frozen); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_7__str___genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_2__str__(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_4__len__(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_4keys_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_6keys(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_8log_probability(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self, PyObject *__pyx_v_symbol); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_5joint_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_10joint(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self, PyObject *__pyx_v_neighbor_values); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_12marginal(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self, PyObject *__pyx_v_neighbor_values); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_14from_sample(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, CYTHON_UNUSED PyObject *__pyx_v_inertia, CYTHON_UNUSED PyObject *__pyx_v_pseudocount); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters_4__del__(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable___init__(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self, PyObject *__pyx_v_table, PyObject *__pyx_v_neighbors, PyObject *__pyx_v_keys, CYTHON_UNUSED PyObject *__pyx_v_frozen); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_7__str___genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_2__str__(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_4__len__(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_4keys_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_6keys(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_8log_probability(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self, PyObject *__pyx_v_symbol); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_10marginal(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self, PyObject *__pyx_v_wrt, PyObject *__pyx_v_neighbor_values); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_12from_sample(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, CYTHON_UNUSED PyObject *__pyx_v_inertia, CYTHON_UNUSED PyObject *__pyx_v_pseudocount); /* proto */
static PyObject *__pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self); /* proto */
static int __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_10parameters_4__del__(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self); /* proto */
static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */
static PyObject *__pyx_tp_new_11pomegranate_13distributions_Distribution(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_UniformDistribution(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_NormalDistribution(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_LogNormalDistribution(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_ExponentialDistribution(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_BetaDistribution(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_GammaDistribution(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_DiscreteDistribution(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_LambdaDistribution(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_KernelDensity(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_GaussianKernelDensity(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_UniformKernelDensity(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_TriangleKernelDensity(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_MixtureDistribution(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_MultivariateDistribution(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_IndependentComponentsDistribution(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_MultivariateGaussianDistribution(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_ConditionalProbabilityTable(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions_JointProbabilityTable(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct____str__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_1_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_2_keys(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_3_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_4_joint(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_5_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_6___str__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_7_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_8_keys(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_9_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items = {0, &__pyx_n_s_items, 0, 0, 0};
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_keys = {0, &__pyx_n_s_keys, 0, 0, 0};
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_values = {0, &__pyx_n_s_values, 0, 0, 0};
static PyObject *__pyx_float_0_;
static PyObject *__pyx_float_1_;
static PyObject *__pyx_float_0_0;
static PyObject *__pyx_float_1_0;
static PyObject *__pyx_float_2_0;
static PyObject *__pyx_float_inf;
static PyObject *__pyx_float_0_01;
static PyObject *__pyx_float_1Eneg_9;
static PyObject *__pyx_float_2_50662827463;
static PyObject *__pyx_float_neg_inf;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_int_12;
static PyObject *__pyx_int_24;
static PyObject *__pyx_int_1000;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_slice__7;
static PyObject *__pyx_slice__9;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_slice__11;
static PyObject *__pyx_slice__13;
static PyObject *__pyx_slice__15;
static PyObject *__pyx_slice__17;
static PyObject *__pyx_slice__19;
static PyObject *__pyx_slice__20;
static PyObject *__pyx_slice__21;
static PyObject *__pyx_slice__22;
static PyObject *__pyx_slice__23;
static PyObject *__pyx_slice__24;
static PyObject *__pyx_slice__26;
static PyObject *__pyx_slice__28;
static PyObject *__pyx_slice__29;
static PyObject *__pyx_slice__32;
static PyObject *__pyx_slice__34;
static PyObject *__pyx_slice__35;
static PyObject *__pyx_slice__36;
static PyObject *__pyx_slice__37;
static PyObject *__pyx_slice__38;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_tuple__33;
static PyObject *__pyx_tuple__39;
static PyObject *__pyx_tuple__40;
static PyObject *__pyx_tuple__41;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__43;
static PyObject *__pyx_tuple__44;
static PyObject *__pyx_tuple__45;
static PyObject *__pyx_tuple__46;
static PyObject *__pyx_tuple__48;
static PyObject *__pyx_codeobj__47;
static PyObject *__pyx_codeobj__49;

/* "pomegranate/distributions.pyx":40
 * DEF LOG_2_PI = 1.83787706641
 * 
 * def log(value):             # <<<<<<<<<<<<<<
 * 	"""
 * 	Return the natural log of the given value, or - infinity if the value is 0.
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_1log(PyObject *__pyx_self, PyObject *__pyx_v_value); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_log[] = "\n\tReturn the natural log of the given value, or - infinity if the value is 0.\n\tCan handle both scalar floats and numpy arrays.\n\t";
static PyMethodDef __pyx_mdef_11pomegranate_13distributions_1log = {"log", (PyCFunction)__pyx_pw_11pomegranate_13distributions_1log, METH_O, __pyx_doc_11pomegranate_13distributions_log};
static PyObject *__pyx_pw_11pomegranate_13distributions_1log(PyObject *__pyx_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("log (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_log(__pyx_self, ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_log(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_v_to_return = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  double __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("log", 0);

  /* "pomegranate/distributions.pyx":46
 * 	"""
 * 
 * 	if isinstance( value, numpy.ndarray ):             # <<<<<<<<<<<<<<
 * 		to_return = numpy.zeros(( value.shape ))
 * 		to_return[ value > 0 ] = numpy.log( value[ value > 0 ] )
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_value, __pyx_ptype_5numpy_ndarray); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pomegranate/distributions.pyx":47
 * 
 * 	if isinstance( value, numpy.ndarray ):
 * 		to_return = numpy.zeros(( value.shape ))             # <<<<<<<<<<<<<<
 * 		to_return[ value > 0 ] = numpy.log( value[ value > 0 ] )
 * 		to_return[ value == 0 ] = NEGINF
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_to_return = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":48
 * 	if isinstance( value, numpy.ndarray ):
 * 		to_return = numpy.zeros(( value.shape ))
 * 		to_return[ value > 0 ] = numpy.log( value[ value > 0 ] )             # <<<<<<<<<<<<<<
 * 		to_return[ value == 0 ] = NEGINF
 * 		return to_return
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_log); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_RichCompare(__pyx_v_value, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyObject_GetItem(__pyx_v_value, __pyx_t_5); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyObject_RichCompare(__pyx_v_value, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (unlikely(PyObject_SetItem(__pyx_v_to_return, __pyx_t_7, __pyx_t_3) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":49
 * 		to_return = numpy.zeros(( value.shape ))
 * 		to_return[ value > 0 ] = numpy.log( value[ value > 0 ] )
 * 		to_return[ value == 0 ] = NEGINF             # <<<<<<<<<<<<<<
 * 		return to_return
 * 	return _log( value )
 */
    __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_v_value, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(PyObject_SetItem(__pyx_v_to_return, __pyx_t_3, __pyx_float_neg_inf) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":50
 * 		to_return[ value > 0 ] = numpy.log( value[ value > 0 ] )
 * 		to_return[ value == 0 ] = NEGINF
 * 		return to_return             # <<<<<<<<<<<<<<
 * 	return _log( value )
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_to_return);
    __pyx_r = __pyx_v_to_return;
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":46
 * 	"""
 * 
 * 	if isinstance( value, numpy.ndarray ):             # <<<<<<<<<<<<<<
 * 		to_return = numpy.zeros(( value.shape ))
 * 		to_return[ value > 0 ] = numpy.log( value[ value > 0 ] )
 */
  }

  /* "pomegranate/distributions.pyx":51
 * 		to_return[ value == 0 ] = NEGINF
 * 		return to_return
 * 	return _log( value )             # <<<<<<<<<<<<<<
 * 
 * def weight_set( items, weights ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyFloat_FromDouble(__pyx_f_11pomegranate_5utils__log(__pyx_t_8)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":40
 * DEF LOG_2_PI = 1.83787706641
 * 
 * def log(value):             # <<<<<<<<<<<<<<
 * 	"""
 * 	Return the natural log of the given value, or - infinity if the value is 0.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.log", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_to_return);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":53
 * 	return _log( value )
 * 
 * def weight_set( items, weights ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	Set the weights to a numpy array of whatever is passed in, or an array of
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_3weight_set(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_2weight_set[] = "\n\tSet the weights to a numpy array of whatever is passed in, or an array of\n\t1's if nothing is passed in.\n\t";
static PyMethodDef __pyx_mdef_11pomegranate_13distributions_3weight_set = {"weight_set", (PyCFunction)__pyx_pw_11pomegranate_13distributions_3weight_set, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_2weight_set};
static PyObject *__pyx_pw_11pomegranate_13distributions_3weight_set(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("weight_set (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("weight_set", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "weight_set") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("weight_set", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.weight_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_2weight_set(__pyx_self, __pyx_v_items, __pyx_v_weights);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_2weight_set(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("weight_set", 0);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":59
 * 	"""
 * 
 * 	items = numpy.array(items, dtype=numpy.float64)             # <<<<<<<<<<<<<<
 * 	if weights is None:
 * 		# Weight everything 1 if no weights specified
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_items);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_items, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":60
 * 
 * 	items = numpy.array(items, dtype=numpy.float64)
 * 	if weights is None:             # <<<<<<<<<<<<<<
 * 		# Weight everything 1 if no weights specified
 * 		weights = numpy.ones(items.shape[0], dtype=numpy.float64)
 */
  __pyx_t_6 = (__pyx_v_weights == Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "pomegranate/distributions.pyx":62
 * 	if weights is None:
 * 		# Weight everything 1 if no weights specified
 * 		weights = numpy.ones(items.shape[0], dtype=numpy.float64)             # <<<<<<<<<<<<<<
 * 	else:
 * 		# Force whatever we have to be a Numpy array
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ones); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_items, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":60
 * 
 * 	items = numpy.array(items, dtype=numpy.float64)
 * 	if weights is None:             # <<<<<<<<<<<<<<
 * 		# Weight everything 1 if no weights specified
 * 		weights = numpy.ones(items.shape[0], dtype=numpy.float64)
 */
    goto __pyx_L3;
  }

  /* "pomegranate/distributions.pyx":65
 * 	else:
 * 		# Force whatever we have to be a Numpy array
 * 		weights = numpy.array(weights, dtype=numpy.float64)             # <<<<<<<<<<<<<<
 * 
 * 	return items, weights
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_weights);
    __Pyx_GIVEREF(__pyx_v_weights);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_weights);
    __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float64); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_2);
    __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "pomegranate/distributions.pyx":67
 * 		weights = numpy.array(weights, dtype=numpy.float64)
 * 
 * 	return items, weights             # <<<<<<<<<<<<<<
 * 
 * cdef class Distribution:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_weights);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":53
 * 	return _log( value )
 * 
 * def weight_set( items, weights ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	Set the weights to a numpy array of whatever is passed in, or an array of
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pomegranate.distributions.weight_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":81
 * 	"""
 * 
 * 	def __cinit__( self ):             # <<<<<<<<<<<<<<
 * 		"""Initialize a new abstract distribution."""
 * 
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_12Distribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_12Distribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution___cinit__(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_12Distribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "pomegranate/distributions.pyx":84
 * 		"""Initialize a new abstract distribution."""
 * 
 * 		self.name = "Distribution"             # <<<<<<<<<<<<<<
 * 		self.frozen = False
 * 		self.summaries = []
 */
  __Pyx_INCREF(__pyx_n_s_Distribution);
  __Pyx_GIVEREF(__pyx_n_s_Distribution);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(__pyx_v_self->name);
  __pyx_v_self->name = __pyx_n_s_Distribution;

  /* "pomegranate/distributions.pyx":85
 * 
 * 		self.name = "Distribution"
 * 		self.frozen = False             # <<<<<<<<<<<<<<
 * 		self.summaries = []
 * 
 */
  __pyx_v_self->frozen = 0;

  /* "pomegranate/distributions.pyx":86
 * 		self.name = "Distribution"
 * 		self.frozen = False
 * 		self.summaries = []             # <<<<<<<<<<<<<<
 * 
 * 	def __str__( self ):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->summaries);
  __Pyx_DECREF(__pyx_v_self->summaries);
  __pyx_v_self->summaries = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":81
 * 	"""
 * 
 * 	def __cinit__( self ):             # <<<<<<<<<<<<<<
 * 		"""Initialize a new abstract distribution."""
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":88
 * 		self.summaries = []
 * 
 * 	def __str__( self ):             # <<<<<<<<<<<<<<
 * 		"""Represent this distribution in JSON."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_3__str__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_12Distribution_2__str__[] = "Represent this distribution in JSON.";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_11pomegranate_13distributions_12Distribution_2__str__;
#endif
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_3__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_2__str__(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_2__str__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "pomegranate/distributions.pyx":91
 * 		"""Represent this distribution in JSON."""
 * 
 * 		return self.to_json()             # <<<<<<<<<<<<<<
 * 
 * 	def __repr__( self ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_to_json); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":88
 * 		self.summaries = []
 * 
 * 	def __str__( self ):             # <<<<<<<<<<<<<<
 * 		"""Represent this distribution in JSON."""
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":93
 * 		return self.to_json()
 * 
 * 	def __repr__( self ):             # <<<<<<<<<<<<<<
 * 		"""Represent this distribution in the same format as string."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_12Distribution_4__repr__[] = "Represent this distribution in the same format as string.";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_11pomegranate_13distributions_12Distribution_4__repr__;
#endif
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_4__repr__(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_4__repr__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "pomegranate/distributions.pyx":96
 * 		"""Represent this distribution in the same format as string."""
 * 
 * 		return self.to_json()             # <<<<<<<<<<<<<<
 * 
 * 	def marginal( self, *args, **kwargs ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_to_json); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":93
 * 		return self.to_json()
 * 
 * 	def __repr__( self ):             # <<<<<<<<<<<<<<
 * 		"""Represent this distribution in the same format as string."""
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":98
 * 		return self.to_json()
 * 
 * 	def marginal( self, *args, **kwargs ):             # <<<<<<<<<<<<<<
 * 		"""Abstract method to return the marginal of the distribution."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_7marginal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_12Distribution_6marginal[] = "Abstract method to return the marginal of the distribution.";
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_7marginal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("marginal (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "marginal", 1))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_6marginal(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_6marginal(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("marginal", 0);

  /* "pomegranate/distributions.pyx":101
 * 		"""Abstract method to return the marginal of the distribution."""
 * 
 * 		return self             # <<<<<<<<<<<<<<
 * 
 * 	def copy( self ):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":98
 * 		return self.to_json()
 * 
 * 	def marginal( self, *args, **kwargs ):             # <<<<<<<<<<<<<<
 * 		"""Abstract method to return the marginal of the distribution."""
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":103
 * 		return self
 * 
 * 	def copy( self ):             # <<<<<<<<<<<<<<
 * 		"""Return a copy of this distribution, untied."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_9copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_12Distribution_8copy[] = "Return a copy of this distribution, untied.";
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_9copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_8copy(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_8copy(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("copy", 0);

  /* "pomegranate/distributions.pyx":106
 * 		"""Return a copy of this distribution, untied."""
 * 
 * 		return self.__class__( *self.parameters )             # <<<<<<<<<<<<<<
 * 
 * 	def freeze( self ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PySequence_Tuple(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":103
 * 		return self
 * 
 * 	def copy( self ):             # <<<<<<<<<<<<<<
 * 		"""Return a copy of this distribution, untied."""
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":108
 * 		return self.__class__( *self.parameters )
 * 
 * 	def freeze( self ):             # <<<<<<<<<<<<<<
 * 		"""Freeze the distribution, preventing updates from occuring."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_11freeze(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_12Distribution_10freeze[] = "Freeze the distribution, preventing updates from occuring.";
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_11freeze(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("freeze (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_10freeze(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_10freeze(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("freeze", 0);

  /* "pomegranate/distributions.pyx":111
 * 		"""Freeze the distribution, preventing updates from occuring."""
 * 
 * 		self.frozen = True             # <<<<<<<<<<<<<<
 * 
 * 	def thaw( self ):
 */
  __pyx_v_self->frozen = 1;

  /* "pomegranate/distributions.pyx":108
 * 		return self.__class__( *self.parameters )
 * 
 * 	def freeze( self ):             # <<<<<<<<<<<<<<
 * 		"""Freeze the distribution, preventing updates from occuring."""
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":113
 * 		self.frozen = True
 * 
 * 	def thaw( self ):             # <<<<<<<<<<<<<<
 * 		"""Thaw the distribution, re-allowing updates to occur."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_13thaw(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_12Distribution_12thaw[] = "Thaw the distribution, re-allowing updates to occur.";
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_13thaw(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("thaw (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_12thaw(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_12thaw(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("thaw", 0);

  /* "pomegranate/distributions.pyx":116
 * 		"""Thaw the distribution, re-allowing updates to occur."""
 * 
 * 		self.frozen = False             # <<<<<<<<<<<<<<
 * 
 * 	def log_probability( self, double symbol ):
 */
  __pyx_v_self->frozen = 0;

  /* "pomegranate/distributions.pyx":113
 * 		self.frozen = True
 * 
 * 	def thaw( self ):             # <<<<<<<<<<<<<<
 * 		"""Thaw the distribution, re-allowing updates to occur."""
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":118
 * 		self.frozen = False
 * 
 * 	def log_probability( self, double symbol ):             # <<<<<<<<<<<<<<
 * 		"""Return the log probability of the given symbol under this distribution."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_15log_probability(PyObject *__pyx_v_self, PyObject *__pyx_arg_symbol); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_12Distribution_14log_probability[] = "Return the log probability of the given symbol under this distribution.";
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_15log_probability(PyObject *__pyx_v_self, PyObject *__pyx_arg_symbol) {
  double __pyx_v_symbol;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("log_probability (wrapper)", 0);
  assert(__pyx_arg_symbol); {
    __pyx_v_symbol = __pyx_PyFloat_AsDouble(__pyx_arg_symbol); if (unlikely((__pyx_v_symbol == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.log_probability", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_14log_probability(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), ((double)__pyx_v_symbol));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_14log_probability(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, double __pyx_v_symbol) {
  double __pyx_v_logp;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("log_probability", 0);

  /* "pomegranate/distributions.pyx":122
 * 
 * 		cdef double logp
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			logp = self._log_probability( symbol )
 * 		return logp
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "pomegranate/distributions.pyx":123
 * 		cdef double logp
 * 		with nogil:
 * 			logp = self._log_probability( symbol )             # <<<<<<<<<<<<<<
 * 		return logp
 * 
 */
        __pyx_v_logp = ((struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution *)__pyx_v_self->__pyx_vtab)->_log_probability(__pyx_v_self, __pyx_v_symbol);
      }

      /* "pomegranate/distributions.pyx":122
 * 
 * 		cdef double logp
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			logp = self._log_probability( symbol )
 * 		return logp
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "pomegranate/distributions.pyx":124
 * 		with nogil:
 * 			logp = self._log_probability( symbol )
 * 		return logp             # <<<<<<<<<<<<<<
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_logp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":118
 * 		self.frozen = False
 * 
 * 	def log_probability( self, double symbol ):             # <<<<<<<<<<<<<<
 * 		"""Return the log probability of the given symbol under this distribution."""
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.log_probability", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":126
 * 		return logp
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Placeholder for the log probability calculation."""
 * 		return NEGINF
 */

static double __pyx_f_11pomegranate_13distributions_12Distribution__log_probability(CYTHON_UNUSED struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, CYTHON_UNUSED double __pyx_v_symbol) {
  double __pyx_r;

  /* "pomegranate/distributions.pyx":128
 * 	cdef double _log_probability( self, double symbol ) nogil:
 * 		"""Placeholder for the log probability calculation."""
 * 		return NEGINF             # <<<<<<<<<<<<<<
 * 
 * 	cdef double _mv_log_probability( self, double* symbol ) nogil:
 */
  __pyx_r = (-Py_HUGE_VAL);
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":126
 * 		return logp
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Placeholder for the log probability calculation."""
 * 		return NEGINF
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":130
 * 		return NEGINF
 * 
 * 	cdef double _mv_log_probability( self, double* symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Placeholder for log probability calculation of a vector."""
 * 		return NEGINF
 */

static double __pyx_f_11pomegranate_13distributions_12Distribution__mv_log_probability(CYTHON_UNUSED struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, CYTHON_UNUSED double *__pyx_v_symbol) {
  double __pyx_r;

  /* "pomegranate/distributions.pyx":132
 * 	cdef double _mv_log_probability( self, double* symbol ) nogil:
 * 		"""Placeholder for log probability calculation of a vector."""
 * 		return NEGINF             # <<<<<<<<<<<<<<
 * 
 * 	def sample( self ):
 */
  __pyx_r = (-Py_HUGE_VAL);
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":130
 * 		return NEGINF
 * 
 * 	cdef double _mv_log_probability( self, double* symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Placeholder for log probability calculation of a vector."""
 * 		return NEGINF
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":134
 * 		return NEGINF
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""Return a random item sampled from this distribution."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_17sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_12Distribution_16sample[] = "Return a random item sampled from this distribution.";
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_17sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_16sample(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_16sample(CYTHON_UNUSED struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);

  /* "pomegranate/distributions.pyx":137
 * 		"""Return a random item sampled from this distribution."""
 * 
 * 		raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 * 	def fit( self, items, weights=None, inertia=0.0 ):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "pomegranate/distributions.pyx":134
 * 		return NEGINF
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""Return a random item sampled from this distribution."""
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":139
 * 		raise NotImplementedError
 * 
 * 	def fit( self, items, weights=None, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""sklearn wrapper for fitting a distribution."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_19fit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_12Distribution_18fit[] = "sklearn wrapper for fitting a distribution.";
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_19fit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fit (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,&__pyx_n_s_inertia,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fit") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_inertia = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("fit", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.fit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_18fit(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights, __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_18fit(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fit", 0);

  /* "pomegranate/distributions.pyx":142
 * 		"""sklearn wrapper for fitting a distribution."""
 * 
 * 		self.from_sample( items, weights, inertia )             # <<<<<<<<<<<<<<
 * 
 * 	def train( self, items, weights=None, inertia=0.0 ):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_sample); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_3) {
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  }
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_weights);
  __Pyx_INCREF(__pyx_v_inertia);
  __Pyx_GIVEREF(__pyx_v_inertia);
  PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_inertia);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":139
 * 		raise NotImplementedError
 * 
 * 	def fit( self, items, weights=None, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""sklearn wrapper for fitting a distribution."""
 * 
 */

  /* function exit code */
  __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_5);
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.fit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":144
 * 		self.from_sample( items, weights, inertia )
 * 
 * 	def train( self, items, weights=None, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""A wrapper for from_sample in order to homogenize calls more."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_21train(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_12Distribution_20train[] = "A wrapper for from_sample in order to homogenize calls more.";
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_21train(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("train (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,&__pyx_n_s_inertia,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "train") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_inertia = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("train", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.train", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_20train(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights, __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_20train(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("train", 0);

  /* "pomegranate/distributions.pyx":147
 * 		"""A wrapper for from_sample in order to homogenize calls more."""
 * 
 * 		self.from_sample( items, weights, inertia )             # <<<<<<<<<<<<<<
 * 
 * 	def from_sample( self, items, weights=None, inertia=0.0 ):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_sample); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_3) {
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  }
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_weights);
  __Pyx_INCREF(__pyx_v_inertia);
  __Pyx_GIVEREF(__pyx_v_inertia);
  PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_inertia);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":144
 * 		self.from_sample( items, weights, inertia )
 * 
 * 	def train( self, items, weights=None, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""A wrapper for from_sample in order to homogenize calls more."""
 * 
 */

  /* function exit code */
  __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_5);
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.train", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":149
 * 		self.from_sample( items, weights, inertia )
 * 
 * 	def from_sample( self, items, weights=None, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""Set the parameters of this distribution using MLE estimates."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_23from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_12Distribution_22from_sample[] = "Set the parameters of this distribution using MLE estimates.";
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_23from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_items = 0;
  CYTHON_UNUSED PyObject *__pyx_v_weights = 0;
  CYTHON_UNUSED PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,&__pyx_n_s_inertia,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_inertia = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_sample", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_22from_sample(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights, __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_22from_sample(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_items, CYTHON_UNUSED PyObject *__pyx_v_weights, CYTHON_UNUSED PyObject *__pyx_v_inertia) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_sample", 0);

  /* "pomegranate/distributions.pyx":152
 * 		"""Set the parameters of this distribution using MLE estimates."""
 * 
 * 		if self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 		raise NotImplementedError
 */
  __pyx_t_1 = ((__pyx_v_self->frozen == 1) != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":153
 * 
 * 		if self.frozen == True:
 * 			return             # <<<<<<<<<<<<<<
 * 		raise NotImplementedError
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":152
 * 		"""Set the parameters of this distribution using MLE estimates."""
 * 
 * 		if self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 		raise NotImplementedError
 */
  }

  /* "pomegranate/distributions.pyx":154
 * 		if self.frozen == True:
 * 			return
 * 		raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 * 	def summarize( self, items, weights=None ):
 */
  __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "pomegranate/distributions.pyx":149
 * 		self.from_sample( items, weights, inertia )
 * 
 * 	def from_sample( self, items, weights=None, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""Set the parameters of this distribution using MLE estimates."""
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":156
 * 		raise NotImplementedError
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Summarize the incoming items into a summary statistic to be used to
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_25summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_12Distribution_24summarize[] = "\n\t\tSummarize the incoming items into a summary statistic to be used to\n\t\tupdate the parameters upon usage of the `from_summaries` method. By\n\t\tdefault, this will simply store the items and weights into a large\n\t\tsample, and call the `from_sample` method.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_25summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("summarize (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "summarize") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("summarize", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_24summarize(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_24summarize(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights) {
  PyObject *__pyx_v_prior_items = NULL;
  PyObject *__pyx_v_prior_weights = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("summarize", 0);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":165
 * 
 * 		# If no previously stored summaries, just store the incoming data
 * 		if len( self.summaries ) == 0:             # <<<<<<<<<<<<<<
 * 			self.summaries = [ items, weights ]
 * 
 */
  __pyx_t_1 = __pyx_v_self->summaries;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((__pyx_t_2 == 0) != 0);
  if (__pyx_t_3) {

    /* "pomegranate/distributions.pyx":166
 * 		# If no previously stored summaries, just store the incoming data
 * 		if len( self.summaries ) == 0:
 * 			self.summaries = [ items, weights ]             # <<<<<<<<<<<<<<
 * 
 * 		# Otherwise, append the items and weights
 */
    __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_items);
    __Pyx_GIVEREF(__pyx_v_items);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_items);
    __Pyx_INCREF(__pyx_v_weights);
    __Pyx_GIVEREF(__pyx_v_weights);
    PyList_SET_ITEM(__pyx_t_1, 1, __pyx_v_weights);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->summaries);
    __Pyx_DECREF(__pyx_v_self->summaries);
    __pyx_v_self->summaries = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":165
 * 
 * 		# If no previously stored summaries, just store the incoming data
 * 		if len( self.summaries ) == 0:             # <<<<<<<<<<<<<<
 * 			self.summaries = [ items, weights ]
 * 
 */
    goto __pyx_L3;
  }

  /* "pomegranate/distributions.pyx":170
 * 		# Otherwise, append the items and weights
 * 		else:
 * 			prior_items, prior_weights = self.summaries             # <<<<<<<<<<<<<<
 * 			items = numpy.concatenate( [prior_items, items] )
 * 
 */
  /*else*/ {
    __pyx_t_1 = __pyx_v_self->summaries;
    __Pyx_INCREF(__pyx_t_1);
    if (likely(__pyx_t_1 != Py_None)) {
      PyObject* sequence = __pyx_t_1;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      #else
      __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_prior_items = __pyx_t_4;
    __pyx_t_4 = 0;
    __pyx_v_prior_weights = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "pomegranate/distributions.pyx":171
 * 		else:
 * 			prior_items, prior_weights = self.summaries
 * 			items = numpy.concatenate( [prior_items, items] )             # <<<<<<<<<<<<<<
 * 
 * 			# If even one summary lacks weights, then weights can't be assigned
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_prior_items);
    __Pyx_GIVEREF(__pyx_v_prior_items);
    PyList_SET_ITEM(__pyx_t_5, 0, __pyx_v_prior_items);
    __Pyx_INCREF(__pyx_v_items);
    __Pyx_GIVEREF(__pyx_v_items);
    PyList_SET_ITEM(__pyx_t_5, 1, __pyx_v_items);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_items, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":175
 * 			# If even one summary lacks weights, then weights can't be assigned
 * 			# to any of the points.
 * 			if weights is not None:             # <<<<<<<<<<<<<<
 * 				weights = numpy.concatenate( [prior_weights, weights] )
 * 
 */
    __pyx_t_3 = (__pyx_v_weights != Py_None);
    __pyx_t_8 = (__pyx_t_3 != 0);
    if (__pyx_t_8) {

      /* "pomegranate/distributions.pyx":176
 * 			# to any of the points.
 * 			if weights is not None:
 * 				weights = numpy.concatenate( [prior_weights, weights] )             # <<<<<<<<<<<<<<
 * 
 * 			self.summaries = [ items, weights ]
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_prior_weights);
      __Pyx_GIVEREF(__pyx_v_prior_weights);
      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_v_prior_weights);
      __Pyx_INCREF(__pyx_v_weights);
      __Pyx_GIVEREF(__pyx_v_weights);
      PyList_SET_ITEM(__pyx_t_4, 1, __pyx_v_weights);
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "pomegranate/distributions.pyx":175
 * 			# If even one summary lacks weights, then weights can't be assigned
 * 			# to any of the points.
 * 			if weights is not None:             # <<<<<<<<<<<<<<
 * 				weights = numpy.concatenate( [prior_weights, weights] )
 * 
 */
    }

    /* "pomegranate/distributions.pyx":178
 * 				weights = numpy.concatenate( [prior_weights, weights] )
 * 
 * 			self.summaries = [ items, weights ]             # <<<<<<<<<<<<<<
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 */
    __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_items);
    __Pyx_GIVEREF(__pyx_v_items);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_items);
    __Pyx_INCREF(__pyx_v_weights);
    __Pyx_GIVEREF(__pyx_v_weights);
    PyList_SET_ITEM(__pyx_t_1, 1, __pyx_v_weights);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->summaries);
    __Pyx_DECREF(__pyx_v_self->summaries);
    __pyx_v_self->summaries = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "pomegranate/distributions.pyx":156
 * 		raise NotImplementedError
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Summarize the incoming items into a summary statistic to be used to
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_prior_items);
  __Pyx_XDECREF(__pyx_v_prior_weights);
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":180
 * 			self.summaries = [ items, weights ]
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 
 * 		pass
 */

static void __pyx_f_11pomegranate_13distributions_12Distribution__summarize(CYTHON_UNUSED struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, CYTHON_UNUSED double *__pyx_v_items, CYTHON_UNUSED double *__pyx_v_weights, CYTHON_UNUSED __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n) {

  /* function exit code */
}

/* "pomegranate/distributions.pyx":184
 * 		pass
 * 
 * 	def from_summaries( self, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Update the parameters of the distribution based on the summaries stored
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_27from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_12Distribution_26from_summaries[] = "\n\t\tUpdate the parameters of the distribution based on the summaries stored\n\t\tpreviously. \n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_27from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_summaries (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_inertia,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_summaries") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_inertia = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_summaries", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_26from_summaries(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_26from_summaries(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, PyObject *__pyx_v_inertia) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_summaries", 0);

  /* "pomegranate/distributions.pyx":191
 * 
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->frozen == 1) != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":192
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if self.frozen == True:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		self.train( *self.summaries, inertia=inertia )
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":191
 * 
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":194
 * 			return
 * 
 * 		self.train( *self.summaries, inertia=inertia )             # <<<<<<<<<<<<<<
 * 		self.summaries = []
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_train); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PySequence_Tuple(__pyx_v_self->summaries); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_inertia, __pyx_v_inertia) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":195
 * 
 * 		self.train( *self.summaries, inertia=inertia )
 * 		self.summaries = []             # <<<<<<<<<<<<<<
 * 
 * 	def plot( self, n=1000, **kwargs ):
 */
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_GOTREF(__pyx_v_self->summaries);
  __Pyx_DECREF(__pyx_v_self->summaries);
  __pyx_v_self->summaries = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":184
 * 		pass
 * 
 * 	def from_summaries( self, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Update the parameters of the distribution based on the summaries stored
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":197
 * 		self.summaries = []
 * 
 * 	def plot( self, n=1000, **kwargs ):             # <<<<<<<<<<<<<<
 * 		"""Plot the distribution by sampling from it."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_29plot(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_12Distribution_28plot[] = "Plot the distribution by sampling from it.";
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_29plot(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_n = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("plot (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_1000);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "plot") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_n = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("plot", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.plot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_28plot(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), __pyx_v_n, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_28plot(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, PyObject *__pyx_v_n, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_plt = NULL;
  PyObject *__pyx_v_samples = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("plot", 0);

  /* "pomegranate/distributions.pyx":200
 * 		"""Plot the distribution by sampling from it."""
 * 
 * 		import matplotlib.pyplot as plt             # <<<<<<<<<<<<<<
 * 		samples = [ self.sample() for i in xrange( n ) ]
 * 		plt.hist( samples, **kwargs )
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_);
  __Pyx_GIVEREF(__pyx_n_s_);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_matplotlib_pyplot, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_plt = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":201
 * 
 * 		import matplotlib.pyplot as plt
 * 		samples = [ self.sample() for i in xrange( n ) ]             # <<<<<<<<<<<<<<
 * 		plt.hist( samples, **kwargs )
 * 
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_xrange); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_INCREF(__pyx_v_n);
    __Pyx_GIVEREF(__pyx_v_n);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_n);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_7(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_sample); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_samples = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":202
 * 		import matplotlib.pyplot as plt
 * 		samples = [ self.sample() for i in xrange( n ) ]
 * 		plt.hist( samples, **kwargs )             # <<<<<<<<<<<<<<
 * 
 * 	def to_json( self ):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_hist); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_samples);
  __Pyx_GIVEREF(__pyx_v_samples);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_samples);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_v_kwargs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":197
 * 		self.summaries = []
 * 
 * 	def plot( self, n=1000, **kwargs ):             # <<<<<<<<<<<<<<
 * 		"""Plot the distribution by sampling from it."""
 * 
 */

  /* function exit code */
  __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);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.plot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_plt);
  __Pyx_XDECREF(__pyx_v_samples);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":204
 * 		plt.hist( samples, **kwargs )
 * 
 * 	def to_json( self ):             # <<<<<<<<<<<<<<
 * 		"""Convert the distribution to JSON format."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_31to_json(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_12Distribution_30to_json[] = "Convert the distribution to JSON format.";
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_31to_json(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_json (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_30to_json(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_30to_json(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_json", 0);

  /* "pomegranate/distributions.pyx":207
 * 		"""Convert the distribution to JSON format."""
 * 
 * 		return json.dumps( {             # <<<<<<<<<<<<<<
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_json); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dumps); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":208
 * 
 * 		return json.dumps( {
 * 								'class' : 'Distribution',             # <<<<<<<<<<<<<<
 * 								'name'  : self.name,
 * 								'parameters' : self.parameters,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_class_2, __pyx_n_s_Distribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "pomegranate/distributions.pyx":209
 * 		return json.dumps( {
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,             # <<<<<<<<<<<<<<
 * 								'parameters' : self.parameters,
 * 								'frozen' : self.frozen
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_self->name) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "pomegranate/distributions.pyx":210
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,
 * 								'parameters' : self.parameters,             # <<<<<<<<<<<<<<
 * 								'frozen' : self.frozen
 * 						   }, separators=(',', ' : ' ), indent=4 )
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_parameters, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":211
 * 								'name'  : self.name,
 * 								'parameters' : self.parameters,
 * 								'frozen' : self.frozen             # <<<<<<<<<<<<<<
 * 						   }, separators=(',', ' : ' ), indent=4 )
 * 
 */
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_self->frozen); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_frozen, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":207
 * 		"""Convert the distribution to JSON format."""
 * 
 * 		return json.dumps( {             # <<<<<<<<<<<<<<
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":212
 * 								'parameters' : self.parameters,
 * 								'frozen' : self.frozen
 * 						   }, separators=(',', ' : ' ), indent=4 )             # <<<<<<<<<<<<<<
 * 
 * 	@classmethod
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_separators, __pyx_tuple__4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_indent, __pyx_int_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "pomegranate/distributions.pyx":207
 * 		"""Convert the distribution to JSON format."""
 * 
 * 		return json.dumps( {             # <<<<<<<<<<<<<<
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,
 */
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":204
 * 		plt.hist( samples, **kwargs )
 * 
 * 	def to_json( self ):             # <<<<<<<<<<<<<<
 * 		"""Convert the distribution to JSON format."""
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.to_json", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":215
 * 
 * 	@classmethod
 * 	def from_json( cls, s ):             # <<<<<<<<<<<<<<
 * 		"""Read in a JSON and produce an appropriate distribution."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_33from_json(PyObject *__pyx_v_cls, PyObject *__pyx_v_s); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_12Distribution_32from_json[] = "Read in a JSON and produce an appropriate distribution.";
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_33from_json(PyObject *__pyx_v_cls, PyObject *__pyx_v_s) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_json (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_32from_json(((PyTypeObject*)__pyx_v_cls), ((PyObject *)__pyx_v_s));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_32from_json(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_s) {
  PyObject *__pyx_v_d = NULL;
  PyObject *__pyx_v_dist = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_json", 0);

  /* "pomegranate/distributions.pyx":218
 * 		"""Read in a JSON and produce an appropriate distribution."""
 * 
 * 		d = json.loads( s )             # <<<<<<<<<<<<<<
 * 
 * 		if ' ' in d['class'] or 'Distribution' not in d['class']:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_json); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_loads); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_s);
    __Pyx_GIVEREF(__pyx_v_s);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_s);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_d = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":220
 * 		d = json.loads( s )
 * 
 * 		if ' ' in d['class'] or 'Distribution' not in d['class']:             # <<<<<<<<<<<<<<
 * 			raise SyntaxError( "Distribution object attempting to read invalid object." )
 * 
 */
  __pyx_t_1 = PyObject_GetItem(__pyx_v_d, __pyx_n_s_class_2); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_kp_s__5, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (!__pyx_t_7) {
  } else {
    __pyx_t_5 = __pyx_t_7;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_1 = PyObject_GetItem(__pyx_v_d, __pyx_n_s_class_2); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_n_s_Distribution, __pyx_t_1, Py_NE)); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = (__pyx_t_7 != 0);
  __pyx_t_5 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_5) {

    /* "pomegranate/distributions.pyx":221
 * 
 * 		if ' ' in d['class'] or 'Distribution' not in d['class']:
 * 			raise SyntaxError( "Distribution object attempting to read invalid object." )             # <<<<<<<<<<<<<<
 * 
 * 		if d['name'] == 'IndependentComponentsDistribution':
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_SyntaxError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "pomegranate/distributions.pyx":220
 * 		d = json.loads( s )
 * 
 * 		if ' ' in d['class'] or 'Distribution' not in d['class']:             # <<<<<<<<<<<<<<
 * 			raise SyntaxError( "Distribution object attempting to read invalid object." )
 * 
 */
  }

  /* "pomegranate/distributions.pyx":223
 * 			raise SyntaxError( "Distribution object attempting to read invalid object." )
 * 
 * 		if d['name'] == 'IndependentComponentsDistribution':             # <<<<<<<<<<<<<<
 * 			d['parameters'][0] = [Distribution.from_json(dist) for dist in d['parameters'][0]]
 * 			return IndependentComponentsDistribution( d['parameters'][0], d['parameters'][1], d['frozen'] )
 */
  __pyx_t_1 = PyObject_GetItem(__pyx_v_d, __pyx_n_s_name); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_IndependentComponentsDistributio, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "pomegranate/distributions.pyx":224
 * 
 * 		if d['name'] == 'IndependentComponentsDistribution':
 * 			d['parameters'][0] = [Distribution.from_json(dist) for dist in d['parameters'][0]]             # <<<<<<<<<<<<<<
 * 			return IndependentComponentsDistribution( d['parameters'][0], d['parameters'][1], d['frozen'] )
 * 		elif d['name'] == 'MixtureDistribution':
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_GetItem(__pyx_v_d, __pyx_n_s_parameters); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
      __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        }
      } else {
        __pyx_t_4 = __pyx_t_9(__pyx_t_3);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_XDECREF_SET(__pyx_v_dist, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_11pomegranate_13distributions_Distribution), __pyx_n_s_from_json); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_10 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_dist); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
      } else {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_INCREF(__pyx_v_dist);
        __Pyx_GIVEREF(__pyx_v_dist);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_dist);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_GetItem(__pyx_v_d, __pyx_n_s_parameters); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__Pyx_SetItemInt(__pyx_t_3, 0, __pyx_t_1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":225
 * 		if d['name'] == 'IndependentComponentsDistribution':
 * 			d['parameters'][0] = [Distribution.from_json(dist) for dist in d['parameters'][0]]
 * 			return IndependentComponentsDistribution( d['parameters'][0], d['parameters'][1], d['frozen'] )             # <<<<<<<<<<<<<<
 * 		elif d['name'] == 'MixtureDistribution':
 * 			d['parameters'][0] = [Distribution.from_json(dist) for dist in d['parameters'][0]]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PyObject_GetItem(__pyx_v_d, __pyx_n_s_parameters); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_GetItem(__pyx_v_d, __pyx_n_s_parameters); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_GetItem(__pyx_v_d, __pyx_n_s_frozen); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_1);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11pomegranate_13distributions_IndependentComponentsDistribution), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":223
 * 			raise SyntaxError( "Distribution object attempting to read invalid object." )
 * 
 * 		if d['name'] == 'IndependentComponentsDistribution':             # <<<<<<<<<<<<<<
 * 			d['parameters'][0] = [Distribution.from_json(dist) for dist in d['parameters'][0]]
 * 			return IndependentComponentsDistribution( d['parameters'][0], d['parameters'][1], d['frozen'] )
 */
  }

  /* "pomegranate/distributions.pyx":226
 * 			d['parameters'][0] = [Distribution.from_json(dist) for dist in d['parameters'][0]]
 * 			return IndependentComponentsDistribution( d['parameters'][0], d['parameters'][1], d['frozen'] )
 * 		elif d['name'] == 'MixtureDistribution':             # <<<<<<<<<<<<<<
 * 			d['parameters'][0] = [Distribution.from_json(dist) for dist in d['parameters'][0]]
 * 			return MixtureDistribution( d['parameters'][0], d['parameters'][1], d['frozen'] )
 */
  __pyx_t_1 = PyObject_GetItem(__pyx_v_d, __pyx_n_s_name); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_MixtureDistribution, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "pomegranate/distributions.pyx":227
 * 			return IndependentComponentsDistribution( d['parameters'][0], d['parameters'][1], d['frozen'] )
 * 		elif d['name'] == 'MixtureDistribution':
 * 			d['parameters'][0] = [Distribution.from_json(dist) for dist in d['parameters'][0]]             # <<<<<<<<<<<<<<
 * 			return MixtureDistribution( d['parameters'][0], d['parameters'][1], d['frozen'] )
 * 		else:
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_GetItem(__pyx_v_d, __pyx_n_s_parameters); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
      __pyx_t_2 = __pyx_t_4; __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        }
      } else {
        __pyx_t_4 = __pyx_t_9(__pyx_t_2);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_XDECREF_SET(__pyx_v_dist, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_11pomegranate_13distributions_Distribution), __pyx_n_s_from_json); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_11 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_11) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_dist); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
      } else {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = NULL;
        __Pyx_INCREF(__pyx_v_dist);
        __Pyx_GIVEREF(__pyx_v_dist);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_dist);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_GetItem(__pyx_v_d, __pyx_n_s_parameters); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(__Pyx_SetItemInt(__pyx_t_2, 0, __pyx_t_1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":228
 * 		elif d['name'] == 'MixtureDistribution':
 * 			d['parameters'][0] = [Distribution.from_json(dist) for dist in d['parameters'][0]]
 * 			return MixtureDistribution( d['parameters'][0], d['parameters'][1], d['frozen'] )             # <<<<<<<<<<<<<<
 * 		else:
 * 			dist = eval( "{}( {}, frozen={} )".format( d['name'],
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PyObject_GetItem(__pyx_v_d, __pyx_n_s_parameters); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __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_GetItem(__pyx_v_d, __pyx_n_s_parameters); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_GetItem(__pyx_v_d, __pyx_n_s_frozen); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11pomegranate_13distributions_MixtureDistribution), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":226
 * 			d['parameters'][0] = [Distribution.from_json(dist) for dist in d['parameters'][0]]
 * 			return IndependentComponentsDistribution( d['parameters'][0], d['parameters'][1], d['frozen'] )
 * 		elif d['name'] == 'MixtureDistribution':             # <<<<<<<<<<<<<<
 * 			d['parameters'][0] = [Distribution.from_json(dist) for dist in d['parameters'][0]]
 * 			return MixtureDistribution( d['parameters'][0], d['parameters'][1], d['frozen'] )
 */
  }

  /* "pomegranate/distributions.pyx":230
 * 			return MixtureDistribution( d['parameters'][0], d['parameters'][1], d['frozen'] )
 * 		else:
 * 			dist = eval( "{}( {}, frozen={} )".format( d['name'],             # <<<<<<<<<<<<<<
 * 			                                    ','.join( map( str, d['parameters'] ) ),
 * 			                                     d['frozen']) )
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_frozen_2, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_GetItem(__pyx_v_d, __pyx_n_s_name); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);

    /* "pomegranate/distributions.pyx":231
 * 		else:
 * 			dist = eval( "{}( {}, frozen={} )".format( d['name'],
 * 			                                    ','.join( map( str, d['parameters'] ) ),             # <<<<<<<<<<<<<<
 * 			                                     d['frozen']) )
 * 			return dist
 */
    __pyx_t_2 = PyObject_GetItem(__pyx_v_d, __pyx_n_s_parameters); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_INCREF(((PyObject *)(&PyString_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
    PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)(&PyString_Type)));
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyString_Join(__pyx_kp_s__2, __pyx_t_2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pomegranate/distributions.pyx":232
 * 			dist = eval( "{}( {}, frozen={} )".format( d['name'],
 * 			                                    ','.join( map( str, d['parameters'] ) ),
 * 			                                     d['frozen']) )             # <<<<<<<<<<<<<<
 * 			return dist
 * 
 */
    __pyx_t_2 = PyObject_GetItem(__pyx_v_d, __pyx_n_s_frozen); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_11 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_8 = 1;
      }
    }
    __pyx_t_12 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_11) {
      __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_8, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_8, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_8, __pyx_t_2);
    __pyx_t_4 = 0;
    __pyx_t_10 = 0;
    __pyx_t_2 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":230
 * 			return MixtureDistribution( d['parameters'][0], d['parameters'][1], d['frozen'] )
 * 		else:
 * 			dist = eval( "{}( {}, frozen={} )".format( d['name'],             # <<<<<<<<<<<<<<
 * 			                                    ','.join( map( str, d['parameters'] ) ),
 * 			                                     d['frozen']) )
 */
    __pyx_t_3 = __Pyx_Globals(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    if (((PyObject *)__pyx_v_cls)) {
      if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_cls, ((PyObject *)__pyx_v_cls)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (__pyx_v_d) {
      if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_d, __pyx_v_d) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (__pyx_v_dist) {
      if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_dist, __pyx_v_dist) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (__pyx_v_s) {
      if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_s, __pyx_v_s) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_12);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_PyObject_Call(__pyx_builtin_eval, __pyx_t_2, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_dist = __pyx_t_12;
    __pyx_t_12 = 0;

    /* "pomegranate/distributions.pyx":233
 * 			                                    ','.join( map( str, d['parameters'] ) ),
 * 			                                     d['frozen']) )
 * 			return dist             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_dist);
    __pyx_r = __pyx_v_dist;
    goto __pyx_L0;
  }

  /* "pomegranate/distributions.pyx":215
 * 
 * 	@classmethod
 * 	def from_json( cls, s ):             # <<<<<<<<<<<<<<
 * 		"""Read in a JSON and produce an appropriate distribution."""
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.from_json", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_d);
  __Pyx_XDECREF(__pyx_v_dist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pxd":10
 * 
 * cdef class Distribution:
 * 	cdef public str name             # <<<<<<<<<<<<<<
 * 	cdef public list summaries
 * 	cdef public bint frozen
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_4name_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_4name_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_4name___get__(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_4name___get__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->name);
  __pyx_r = __pyx_v_self->name;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_12Distribution_4name_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_12Distribution_4name_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_4name_2__set__(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_12Distribution_4name_2__set__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyString_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(__pyx_v_self->name);
  __pyx_v_self->name = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.name.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_12Distribution_4name_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_12Distribution_4name_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_4name_4__del__(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_12Distribution_4name_4__del__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(__pyx_v_self->name);
  __pyx_v_self->name = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pxd":11
 * cdef class Distribution:
 * 	cdef public str name
 * 	cdef public list summaries             # <<<<<<<<<<<<<<
 * 	cdef public bint frozen
 * 	cdef double _log_probability( self, double symbol ) nogil
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_9summaries_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_9summaries_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_9summaries___get__(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_9summaries___get__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->summaries);
  __pyx_r = __pyx_v_self->summaries;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_12Distribution_9summaries_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_12Distribution_9summaries_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_9summaries_2__set__(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_12Distribution_9summaries_2__set__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyList_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->summaries);
  __Pyx_DECREF(__pyx_v_self->summaries);
  __pyx_v_self->summaries = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.summaries.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_12Distribution_9summaries_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_12Distribution_9summaries_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_9summaries_4__del__(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_12Distribution_9summaries_4__del__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->summaries);
  __Pyx_DECREF(__pyx_v_self->summaries);
  __pyx_v_self->summaries = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pxd":12
 * 	cdef public str name
 * 	cdef public list summaries
 * 	cdef public bint frozen             # <<<<<<<<<<<<<<
 * 	cdef double _log_probability( self, double symbol ) nogil
 * 	cdef double _mv_log_probability( self, double* symbol ) nogil
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_6frozen_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_12Distribution_6frozen_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_6frozen___get__(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_12Distribution_6frozen___get__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->frozen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.frozen.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_12Distribution_6frozen_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_12Distribution_6frozen_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_12Distribution_6frozen_2__set__(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_12Distribution_6frozen_2__set__(struct __pyx_obj_11pomegranate_13distributions_Distribution *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->frozen = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pomegranate.distributions.Distribution.frozen.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":240
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [self.start, self.end]
 * 		def __set__( self, parameters ):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_19UniformDistribution_10parameters_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_19UniformDistribution_10parameters_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_19UniformDistribution_10parameters___get__(((struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_19UniformDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pomegranate/distributions.pyx":241
 * 	property parameters:
 * 		def __get__( self ):
 * 			return [self.start, self.end]             # <<<<<<<<<<<<<<
 * 		def __set__( self, parameters ):
 * 			self.start, self.end = parameters
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->end); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":240
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [self.start, self.end]
 * 		def __set__( self, parameters ):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.UniformDistribution.parameters.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":242
 * 		def __get__( self ):
 * 			return [self.start, self.end]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.start, self.end = parameters
 * 
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_19UniformDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_19UniformDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_19UniformDistribution_10parameters_2__set__(((struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_parameters));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_19UniformDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *(*__pyx_t_4)(PyObject *);
  double __pyx_t_5;
  double __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "pomegranate/distributions.pyx":243
 * 			return [self.start, self.end]
 * 		def __set__( self, parameters ):
 * 			self.start, self.end = parameters             # <<<<<<<<<<<<<<
 * 
 * 	def __cinit__( UniformDistribution self, double start, double end, bint frozen=False ):
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_parameters))) || (PyList_CheckExact(__pyx_v_parameters))) {
    PyObject* sequence = __pyx_v_parameters;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_v_parameters); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->start = __pyx_t_5;
  __pyx_v_self->end = __pyx_t_6;

  /* "pomegranate/distributions.pyx":242
 * 		def __get__( self ):
 * 			return [self.start, self.end]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.start, self.end = parameters
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.UniformDistribution.parameters.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":245
 * 			self.start, self.end = parameters
 * 
 * 	def __cinit__( UniformDistribution self, double start, double end, bint frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Make a new Uniform distribution over floats between start and end,
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_19UniformDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_19UniformDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_start;
  double __pyx_v_end;
  int __pyx_v_frozen;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_start,&__pyx_n_s_end,&__pyx_n_s_frozen,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_end)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_start = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_start == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_end = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_end == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[2]) {
      __pyx_v_frozen = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_frozen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_frozen = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.UniformDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_19UniformDistribution___cinit__(((struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *)__pyx_v_self), __pyx_v_start, __pyx_v_end, __pyx_v_frozen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_19UniformDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self, double __pyx_v_start, double __pyx_v_end, int __pyx_v_frozen) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "pomegranate/distributions.pyx":252
 * 
 * 		# Store the parameters
 * 		self.start = start             # <<<<<<<<<<<<<<
 * 		self.end = end
 * 		self.summaries = [INF, NEGINF]
 */
  __pyx_v_self->start = __pyx_v_start;

  /* "pomegranate/distributions.pyx":253
 * 		# Store the parameters
 * 		self.start = start
 * 		self.end = end             # <<<<<<<<<<<<<<
 * 		self.summaries = [INF, NEGINF]
 * 		self.name = "UniformDistribution"
 */
  __pyx_v_self->end = __pyx_v_end;

  /* "pomegranate/distributions.pyx":254
 * 		self.start = start
 * 		self.end = end
 * 		self.summaries = [INF, NEGINF]             # <<<<<<<<<<<<<<
 * 		self.name = "UniformDistribution"
 * 		self.frozen = frozen
 */
  __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_float_inf);
  __Pyx_GIVEREF(__pyx_float_inf);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_float_inf);
  __Pyx_INCREF(__pyx_float_neg_inf);
  __Pyx_GIVEREF(__pyx_float_neg_inf);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_float_neg_inf);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.summaries);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.summaries);
  __pyx_v_self->__pyx_base.summaries = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":255
 * 		self.end = end
 * 		self.summaries = [INF, NEGINF]
 * 		self.name = "UniformDistribution"             # <<<<<<<<<<<<<<
 * 		self.frozen = frozen
 * 
 */
  __Pyx_INCREF(__pyx_n_s_UniformDistribution);
  __Pyx_GIVEREF(__pyx_n_s_UniformDistribution);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.name);
  __pyx_v_self->__pyx_base.name = __pyx_n_s_UniformDistribution;

  /* "pomegranate/distributions.pyx":256
 * 		self.summaries = [INF, NEGINF]
 * 		self.name = "UniformDistribution"
 * 		self.frozen = frozen             # <<<<<<<<<<<<<<
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:
 */
  __pyx_v_self->__pyx_base.frozen = __pyx_v_frozen;

  /* "pomegranate/distributions.pyx":245
 * 			self.start, self.end = parameters
 * 
 * 	def __cinit__( UniformDistribution self, double start, double end, bint frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Make a new Uniform distribution over floats between start and end,
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.UniformDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":258
 * 		self.frozen = frozen
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

static double __pyx_f_11pomegranate_13distributions_19UniformDistribution__log_probability(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self, double __pyx_v_symbol) {
  double __pyx_v_start;
  double __pyx_v_end;
  double __pyx_r;
  double __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;

  /* "pomegranate/distributions.pyx":261
 * 		"""Cython optimized function for log probability calculation."""
 * 
 * 		cdef double start = self.start             # <<<<<<<<<<<<<<
 * 		cdef double end = self.end
 * 
 */
  __pyx_t_1 = __pyx_v_self->start;
  __pyx_v_start = __pyx_t_1;

  /* "pomegranate/distributions.pyx":262
 * 
 * 		cdef double start = self.start
 * 		cdef double end = self.end             # <<<<<<<<<<<<<<
 * 
 * 		if symbol == start and symbol == end:
 */
  __pyx_t_1 = __pyx_v_self->end;
  __pyx_v_end = __pyx_t_1;

  /* "pomegranate/distributions.pyx":264
 * 		cdef double end = self.end
 * 
 * 		if symbol == start and symbol == end:             # <<<<<<<<<<<<<<
 * 			return 0
 * 		if symbol >= start and symbol <= end:
 */
  __pyx_t_3 = ((__pyx_v_symbol == __pyx_v_start) != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_2 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = ((__pyx_v_symbol == __pyx_v_end) != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pomegranate/distributions.pyx":265
 * 
 * 		if symbol == start and symbol == end:
 * 			return 0             # <<<<<<<<<<<<<<
 * 		if symbol >= start and symbol <= end:
 * 			return _log( 1.0 / ( end - start ) )
 */
    __pyx_r = 0.0;
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":264
 * 		cdef double end = self.end
 * 
 * 		if symbol == start and symbol == end:             # <<<<<<<<<<<<<<
 * 			return 0
 * 		if symbol >= start and symbol <= end:
 */
  }

  /* "pomegranate/distributions.pyx":266
 * 		if symbol == start and symbol == end:
 * 			return 0
 * 		if symbol >= start and symbol <= end:             # <<<<<<<<<<<<<<
 * 			return _log( 1.0 / ( end - start ) )
 * 		return NEGINF
 */
  __pyx_t_3 = ((__pyx_v_symbol >= __pyx_v_start) != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_2 = __pyx_t_3;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_3 = ((__pyx_v_symbol <= __pyx_v_end) != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pomegranate/distributions.pyx":267
 * 			return 0
 * 		if symbol >= start and symbol <= end:
 * 			return _log( 1.0 / ( end - start ) )             # <<<<<<<<<<<<<<
 * 		return NEGINF
 * 
 */
    __pyx_r = __pyx_f_11pomegranate_5utils__log((1.0 / (__pyx_v_end - __pyx_v_start)));
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":266
 * 		if symbol == start and symbol == end:
 * 			return 0
 * 		if symbol >= start and symbol <= end:             # <<<<<<<<<<<<<<
 * 			return _log( 1.0 / ( end - start ) )
 * 		return NEGINF
 */
  }

  /* "pomegranate/distributions.pyx":268
 * 		if symbol >= start and symbol <= end:
 * 			return _log( 1.0 / ( end - start ) )
 * 		return NEGINF             # <<<<<<<<<<<<<<
 * 
 * 	def sample( self ):
 */
  __pyx_r = (-Py_HUGE_VAL);
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":258
 * 		self.frozen = frozen
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":270
 * 		return NEGINF
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""Sample from this uniform distribution and return the value sampled."""
 * 		return random.uniform(self.start, self.end)
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_19UniformDistribution_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_19UniformDistribution_2sample[] = "Sample from this uniform distribution and return the value sampled.";
static PyObject *__pyx_pw_11pomegranate_13distributions_19UniformDistribution_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_19UniformDistribution_2sample(((struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_19UniformDistribution_2sample(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);

  /* "pomegranate/distributions.pyx":272
 * 	def sample( self ):
 * 		"""Sample from this uniform distribution and return the value sampled."""
 * 		return random.uniform(self.start, self.end)             # <<<<<<<<<<<<<<
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0 ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_uniform); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->start); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->end); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_5) {
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":270
 * 		return NEGINF
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""Sample from this uniform distribution and return the value sampled."""
 * 		return random.uniform(self.start, self.end)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.UniformDistribution.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":274
 * 		return random.uniform(self.start, self.end)
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_19UniformDistribution_5from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_19UniformDistribution_4from_sample[] = "\n\t\tSet the parameters of this Distribution to maximize the likelihood of \n\t\tthe given sample. Items holds some sort of sequence. If weights is \n\t\tspecified, it holds a sequence of value to weight each item by.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_19UniformDistribution_5from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,&__pyx_n_s_inertia,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_inertia = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_sample", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.UniformDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_19UniformDistribution_4from_sample(((struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights, __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_19UniformDistribution_4from_sample(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_sample", 0);

  /* "pomegranate/distributions.pyx":281
 * 		"""
 * 
 * 		if self.frozen:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_1 = (__pyx_v_self->__pyx_base.frozen != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":282
 * 
 * 		if self.frozen:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		self.summarize( items, weights )
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":281
 * 		"""
 * 
 * 		if self.frozen:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":284
 * 			return
 * 
 * 		self.summarize( items, weights )             # <<<<<<<<<<<<<<
 * 		self.from_summaries( inertia )
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_summarize); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_4) {
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  }
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_weights);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":285
 * 
 * 		self.summarize( items, weights )
 * 		self.from_summaries( inertia )             # <<<<<<<<<<<<<<
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_summaries); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_inertia); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_INCREF(__pyx_v_inertia);
    __Pyx_GIVEREF(__pyx_v_inertia);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_inertia);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":274
 * 		return random.uniform(self.start, self.end)
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pomegranate.distributions.UniformDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":287
 * 		self.from_summaries( inertia )
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized training."""
 * 
 */

static void __pyx_f_11pomegranate_13distributions_19UniformDistribution__summarize(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self, double *__pyx_v_items, CYTHON_UNUSED double *__pyx_v_weights, __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n) {
  double __pyx_v_minimum;
  double __pyx_v_maximum;
  int __pyx_v_i;
  __Pyx_RefNannyDeclarations
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_summarize", 0);
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif

  /* "pomegranate/distributions.pyx":288
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 * 		"""Cython optimized training."""             # <<<<<<<<<<<<<<
 * 
 * 		cdef double minimum = INF, maximum = NEGINF
 */
  /*try:*/ {

    /* "pomegranate/distributions.pyx":290
 * 		"""Cython optimized training."""
 * 
 * 		cdef double minimum = INF, maximum = NEGINF             # <<<<<<<<<<<<<<
 * 		cdef int i
 * 
 */
    __pyx_v_minimum = Py_HUGE_VAL;
    __pyx_v_maximum = (-Py_HUGE_VAL);

    /* "pomegranate/distributions.pyx":293
 * 		cdef int i
 * 
 * 		for i in range(n):             # <<<<<<<<<<<<<<
 * 			if items[i] < minimum:
 * 				minimum = items[i]
 */
    __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;

      /* "pomegranate/distributions.pyx":294
 * 
 * 		for i in range(n):
 * 			if items[i] < minimum:             # <<<<<<<<<<<<<<
 * 				minimum = items[i]
 * 			if items[i] > maximum:
 */
      __pyx_t_3 = (((__pyx_v_items[__pyx_v_i]) < __pyx_v_minimum) != 0);
      if (__pyx_t_3) {

        /* "pomegranate/distributions.pyx":295
 * 		for i in range(n):
 * 			if items[i] < minimum:
 * 				minimum = items[i]             # <<<<<<<<<<<<<<
 * 			if items[i] > maximum:
 * 				maximum = items[i]
 */
        __pyx_v_minimum = (__pyx_v_items[__pyx_v_i]);

        /* "pomegranate/distributions.pyx":294
 * 
 * 		for i in range(n):
 * 			if items[i] < minimum:             # <<<<<<<<<<<<<<
 * 				minimum = items[i]
 * 			if items[i] > maximum:
 */
      }

      /* "pomegranate/distributions.pyx":296
 * 			if items[i] < minimum:
 * 				minimum = items[i]
 * 			if items[i] > maximum:             # <<<<<<<<<<<<<<
 * 				maximum = items[i]
 * 
 */
      __pyx_t_3 = (((__pyx_v_items[__pyx_v_i]) > __pyx_v_maximum) != 0);
      if (__pyx_t_3) {

        /* "pomegranate/distributions.pyx":297
 * 				minimum = items[i]
 * 			if items[i] > maximum:
 * 				maximum = items[i]             # <<<<<<<<<<<<<<
 * 
 * 		with gil:
 */
        __pyx_v_maximum = (__pyx_v_items[__pyx_v_i]);

        /* "pomegranate/distributions.pyx":296
 * 			if items[i] < minimum:
 * 				minimum = items[i]
 * 			if items[i] > maximum:             # <<<<<<<<<<<<<<
 * 				maximum = items[i]
 * 
 */
      }
    }

    /* "pomegranate/distributions.pyx":299
 * 				maximum = items[i]
 * 
 * 		with gil:             # <<<<<<<<<<<<<<
 * 			if maximum > self.summaries[1]:
 * 				self.summaries[1] = maximum
 */
    {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        /*try:*/ {

          /* "pomegranate/distributions.pyx":300
 * 
 * 		with gil:
 * 			if maximum > self.summaries[1]:             # <<<<<<<<<<<<<<
 * 				self.summaries[1] = maximum
 * 			if minimum < self.summaries[0]:
 */
          __pyx_t_4 = PyFloat_FromDouble(__pyx_v_maximum); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
          __Pyx_GOTREF(__pyx_t_4);
          if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
          }
          __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 1), Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (__pyx_t_3) {

            /* "pomegranate/distributions.pyx":301
 * 		with gil:
 * 			if maximum > self.summaries[1]:
 * 				self.summaries[1] = maximum             # <<<<<<<<<<<<<<
 * 			if minimum < self.summaries[0]:
 * 				self.summaries[0] = minimum
 */
            __pyx_t_5 = PyFloat_FromDouble(__pyx_v_maximum); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
            __Pyx_GOTREF(__pyx_t_5);
            if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
              PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
            }
            if (unlikely(__Pyx_SetItemInt(__pyx_v_self->__pyx_base.summaries, 1, __pyx_t_5, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

            /* "pomegranate/distributions.pyx":300
 * 
 * 		with gil:
 * 			if maximum > self.summaries[1]:             # <<<<<<<<<<<<<<
 * 				self.summaries[1] = maximum
 * 			if minimum < self.summaries[0]:
 */
          }

          /* "pomegranate/distributions.pyx":302
 * 			if maximum > self.summaries[1]:
 * 				self.summaries[1] = maximum
 * 			if minimum < self.summaries[0]:             # <<<<<<<<<<<<<<
 * 				self.summaries[0] = minimum
 * 
 */
          __pyx_t_5 = PyFloat_FromDouble(__pyx_v_minimum); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
          __Pyx_GOTREF(__pyx_t_5);
          if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
          }
          __pyx_t_4 = PyObject_RichCompare(__pyx_t_5, PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 0), Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (__pyx_t_3) {

            /* "pomegranate/distributions.pyx":303
 * 				self.summaries[1] = maximum
 * 			if minimum < self.summaries[0]:
 * 				self.summaries[0] = minimum             # <<<<<<<<<<<<<<
 * 
 * 	def summarize( self, items, weights=None ):
 */
            __pyx_t_4 = PyFloat_FromDouble(__pyx_v_minimum); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
            __Pyx_GOTREF(__pyx_t_4);
            if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
              PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
            }
            if (unlikely(__Pyx_SetItemInt(__pyx_v_self->__pyx_base.summaries, 0, __pyx_t_4, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

            /* "pomegranate/distributions.pyx":302
 * 			if maximum > self.summaries[1]:
 * 				self.summaries[1] = maximum
 * 			if minimum < self.summaries[0]:             # <<<<<<<<<<<<<<
 * 				self.summaries[0] = minimum
 * 
 */
          }
        }

        /* "pomegranate/distributions.pyx":299
 * 				maximum = items[i]
 * 
 * 		with gil:             # <<<<<<<<<<<<<<
 * 			if maximum > self.summaries[1]:
 * 				self.summaries[1] = maximum
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            goto __pyx_L12;
          }
          __pyx_L11_error: {
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            goto __pyx_L4_error;
          }
          __pyx_L12:;
        }
    }
  }

  /* "pomegranate/distributions.pyx":288
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 * 		"""Cython optimized training."""             # <<<<<<<<<<<<<<
 * 
 * 		cdef double minimum = INF, maximum = NEGINF
 */
  /*finally:*/ {
    /*normal exit:*/{
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L5;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "pomegranate/distributions.pyx":287
 * 		self.from_summaries( inertia )
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized training."""
 * 
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("pomegranate.distributions.UniformDistribution._summarize", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 1);
  __pyx_L0:;
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
}

/* "pomegranate/distributions.pyx":305
 * 				self.summaries[0] = minimum
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in a series of items and their weights and reduce it down to a
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_19UniformDistribution_7summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_19UniformDistribution_6summarize[] = "\n\t\tTake in a series of items and their weights and reduce it down to a\n\t\tsummary statistic to be used in training later.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_19UniformDistribution_7summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  CYTHON_UNUSED PyObject *__pyx_v_weights = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("summarize (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "summarize") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("summarize", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.UniformDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_19UniformDistribution_6summarize(((struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_19UniformDistribution_6summarize(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self, PyObject *__pyx_v_items, CYTHON_UNUSED PyObject *__pyx_v_weights) {
  double *__pyx_v_items_p;
  double *__pyx_v_weights_p;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("summarize", 0);
  __Pyx_INCREF(__pyx_v_items);

  /* "pomegranate/distributions.pyx":311
 * 		"""
 * 
 * 		items = numpy.array(items, dtype=numpy.float64)             # <<<<<<<<<<<<<<
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_items);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_items, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":313
 * 		items = numpy.array(items, dtype=numpy.float64)
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data             # <<<<<<<<<<<<<<
 * 		cdef double* weights_p = NULL
 * 		cdef SIZE_t n = items.shape[0]
 */
  __pyx_v_items_p = ((double *)((PyArrayObject *)__pyx_v_items)->data);

  /* "pomegranate/distributions.pyx":314
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 * 		cdef double* weights_p = NULL             # <<<<<<<<<<<<<<
 * 		cdef SIZE_t n = items.shape[0]
 * 
 */
  __pyx_v_weights_p = NULL;

  /* "pomegranate/distributions.pyx":315
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 * 		cdef double* weights_p = NULL
 * 		cdef SIZE_t n = items.shape[0]             # <<<<<<<<<<<<<<
 * 
 * 		with nogil:
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_items, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_Py_intptr_t(__pyx_t_3); if (unlikely((__pyx_t_6 == (npy_intp)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_n = __pyx_t_6;

  /* "pomegranate/distributions.pyx":317
 * 		cdef SIZE_t n = items.shape[0]
 * 
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			self._summarize( items_p, weights_p, n )
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "pomegranate/distributions.pyx":318
 * 
 * 		with nogil:
 * 			self._summarize( items_p, weights_p, n )             # <<<<<<<<<<<<<<
 * 
 * 	def from_summaries( self, inertia=0.0 ):
 */
        ((struct __pyx_vtabstruct_11pomegranate_13distributions_UniformDistribution *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._summarize(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), __pyx_v_items_p, __pyx_v_weights_p, __pyx_v_n);
      }

      /* "pomegranate/distributions.pyx":317
 * 		cdef SIZE_t n = items.shape[0]
 * 
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			self._summarize( items_p, weights_p, n )
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "pomegranate/distributions.pyx":305
 * 				self.summaries[0] = minimum
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in a series of items and their weights and reduce it down to a
 */

  /* function exit code */
  __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);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pomegranate.distributions.UniformDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":320
 * 			self._summarize( items_p, weights_p, n )
 * 
 * 	def from_summaries( self, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Takes in a series of summaries, consisting of the minimum and maximum
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_19UniformDistribution_9from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_19UniformDistribution_8from_summaries[] = "\n\t\tTakes in a series of summaries, consisting of the minimum and maximum\n\t\tof a sample, and determine the global minimum and maximum.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_19UniformDistribution_9from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_summaries (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_inertia,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_summaries") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_inertia = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_summaries", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.UniformDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_19UniformDistribution_8from_summaries(((struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *)__pyx_v_self), __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_19UniformDistribution_8from_summaries(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *__pyx_v_self, PyObject *__pyx_v_inertia) {
  PyObject *__pyx_v_minimum = NULL;
  PyObject *__pyx_v_maximum = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  double __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_summaries", 0);

  /* "pomegranate/distributions.pyx":327
 * 
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->__pyx_base.frozen == 1) != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":328
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if self.frozen == True:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		minimum, maximum = self.summaries
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":327
 * 
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":330
 * 			return
 * 
 * 		minimum, maximum = self.summaries             # <<<<<<<<<<<<<<
 * 		self.start = minimum*(1-inertia) + self.start*inertia
 * 		self.end = maximum*(1-inertia) + self.end*inertia
 */
  __pyx_t_2 = __pyx_v_self->__pyx_base.summaries;
  __Pyx_INCREF(__pyx_t_2);
  if (likely(__pyx_t_2 != Py_None)) {
    PyObject* sequence = __pyx_t_2;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
    __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_minimum = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_maximum = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":331
 * 
 * 		minimum, maximum = self.summaries
 * 		self.start = minimum*(1-inertia) + self.start*inertia             # <<<<<<<<<<<<<<
 * 		self.end = maximum*(1-inertia) + self.end*inertia
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_inertia, 1, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyNumber_Multiply(__pyx_v_minimum, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->start); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_v_inertia); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->start = __pyx_t_5;

  /* "pomegranate/distributions.pyx":332
 * 		minimum, maximum = self.summaries
 * 		self.start = minimum*(1-inertia) + self.start*inertia
 * 		self.end = maximum*(1-inertia) + self.end*inertia             # <<<<<<<<<<<<<<
 * 
 * 		self.summaries = [INF, NEGINF]
 */
  __pyx_t_2 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_inertia, 1, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyNumber_Multiply(__pyx_v_maximum, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->end); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyNumber_Multiply(__pyx_t_2, __pyx_v_inertia); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->end = __pyx_t_5;

  /* "pomegranate/distributions.pyx":334
 * 		self.end = maximum*(1-inertia) + self.end*inertia
 * 
 * 		self.summaries = [INF, NEGINF]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_float_inf);
  __Pyx_GIVEREF(__pyx_float_inf);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_float_inf);
  __Pyx_INCREF(__pyx_float_neg_inf);
  __Pyx_GIVEREF(__pyx_float_neg_inf);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_float_neg_inf);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.summaries);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.summaries);
  __pyx_v_self->__pyx_base.summaries = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":320
 * 			self._summarize( items_p, weights_p, n )
 * 
 * 	def from_summaries( self, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Takes in a series of summaries, consisting of the minimum and maximum
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pomegranate.distributions.UniformDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_minimum);
  __Pyx_XDECREF(__pyx_v_maximum);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":343
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [self.mu, self.sigma]
 * 		def __set__( self, parameters ):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_18NormalDistribution_10parameters_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_18NormalDistribution_10parameters_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_18NormalDistribution_10parameters___get__(((struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_18NormalDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pomegranate/distributions.pyx":344
 * 	property parameters:
 * 		def __get__( self ):
 * 			return [self.mu, self.sigma]             # <<<<<<<<<<<<<<
 * 		def __set__( self, parameters ):
 * 			self.mu, self.sigma = parameters
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->mu); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->sigma); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":343
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [self.mu, self.sigma]
 * 		def __set__( self, parameters ):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.NormalDistribution.parameters.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":345
 * 		def __get__( self ):
 * 			return [self.mu, self.sigma]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.mu, self.sigma = parameters
 * 
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_18NormalDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_18NormalDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_18NormalDistribution_10parameters_2__set__(((struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_parameters));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_18NormalDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *(*__pyx_t_4)(PyObject *);
  double __pyx_t_5;
  double __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "pomegranate/distributions.pyx":346
 * 			return [self.mu, self.sigma]
 * 		def __set__( self, parameters ):
 * 			self.mu, self.sigma = parameters             # <<<<<<<<<<<<<<
 * 
 * 	def __cinit__( self, double mean, double std, bint frozen=False ):
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_parameters))) || (PyList_CheckExact(__pyx_v_parameters))) {
    PyObject* sequence = __pyx_v_parameters;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_v_parameters); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->mu = __pyx_t_5;
  __pyx_v_self->sigma = __pyx_t_6;

  /* "pomegranate/distributions.pyx":345
 * 		def __get__( self ):
 * 			return [self.mu, self.sigma]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.mu, self.sigma = parameters
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.NormalDistribution.parameters.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":348
 * 			self.mu, self.sigma = parameters
 * 
 * 	def __cinit__( self, double mean, double std, bint frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Make a new Normal distribution with the given mean mean and standard
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_18NormalDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_18NormalDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_mean;
  double __pyx_v_std;
  int __pyx_v_frozen;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mean,&__pyx_n_s_std,&__pyx_n_s_frozen,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mean)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_std)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_mean = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_mean == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_std = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_std == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[2]) {
      __pyx_v_frozen = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_frozen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_frozen = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.NormalDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_18NormalDistribution___cinit__(((struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *)__pyx_v_self), __pyx_v_mean, __pyx_v_std, __pyx_v_frozen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_18NormalDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self, double __pyx_v_mean, double __pyx_v_std, int __pyx_v_frozen) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "pomegranate/distributions.pyx":354
 * 		"""
 * 
 * 		self.mu = mean             # <<<<<<<<<<<<<<
 * 		self.sigma = std
 * 		self.name = "NormalDistribution"
 */
  __pyx_v_self->mu = __pyx_v_mean;

  /* "pomegranate/distributions.pyx":355
 * 
 * 		self.mu = mean
 * 		self.sigma = std             # <<<<<<<<<<<<<<
 * 		self.name = "NormalDistribution"
 * 		self.frozen = frozen
 */
  __pyx_v_self->sigma = __pyx_v_std;

  /* "pomegranate/distributions.pyx":356
 * 		self.mu = mean
 * 		self.sigma = std
 * 		self.name = "NormalDistribution"             # <<<<<<<<<<<<<<
 * 		self.frozen = frozen
 * 		self.summaries = [0, 0, 0]
 */
  __Pyx_INCREF(__pyx_n_s_NormalDistribution);
  __Pyx_GIVEREF(__pyx_n_s_NormalDistribution);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.name);
  __pyx_v_self->__pyx_base.name = __pyx_n_s_NormalDistribution;

  /* "pomegranate/distributions.pyx":357
 * 		self.sigma = std
 * 		self.name = "NormalDistribution"
 * 		self.frozen = frozen             # <<<<<<<<<<<<<<
 * 		self.summaries = [0, 0, 0]
 * 		self.log_sigma_sqrt_2_pi = -_log(std * SQRT_2_PI)
 */
  __pyx_v_self->__pyx_base.frozen = __pyx_v_frozen;

  /* "pomegranate/distributions.pyx":358
 * 		self.name = "NormalDistribution"
 * 		self.frozen = frozen
 * 		self.summaries = [0, 0, 0]             # <<<<<<<<<<<<<<
 * 		self.log_sigma_sqrt_2_pi = -_log(std * SQRT_2_PI)
 * 		self.two_sigma_squared = 2 * std ** 2
 */
  __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.summaries);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.summaries);
  __pyx_v_self->__pyx_base.summaries = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":359
 * 		self.frozen = frozen
 * 		self.summaries = [0, 0, 0]
 * 		self.log_sigma_sqrt_2_pi = -_log(std * SQRT_2_PI)             # <<<<<<<<<<<<<<
 * 		self.two_sigma_squared = 2 * std ** 2
 * 
 */
  __pyx_v_self->log_sigma_sqrt_2_pi = (-__pyx_f_11pomegranate_5utils__log((__pyx_v_std * 2.50662827463)));

  /* "pomegranate/distributions.pyx":360
 * 		self.summaries = [0, 0, 0]
 * 		self.log_sigma_sqrt_2_pi = -_log(std * SQRT_2_PI)
 * 		self.two_sigma_squared = 2 * std ** 2             # <<<<<<<<<<<<<<
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:
 */
  __pyx_v_self->two_sigma_squared = (2.0 * pow(__pyx_v_std, 2.0));

  /* "pomegranate/distributions.pyx":348
 * 			self.mu, self.sigma = parameters
 * 
 * 	def __cinit__( self, double mean, double std, bint frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Make a new Normal distribution with the given mean mean and standard
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.NormalDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":362
 * 		self.two_sigma_squared = 2 * std ** 2
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

static double __pyx_f_11pomegranate_13distributions_18NormalDistribution__log_probability(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self, double __pyx_v_symbol) {
  double __pyx_r;

  /* "pomegranate/distributions.pyx":365
 * 		"""Cython optimized function for log probability calculation."""
 * 
 * 		return self.log_sigma_sqrt_2_pi - ((symbol - self.mu) ** 2) /\             # <<<<<<<<<<<<<<
 * 			self.two_sigma_squared
 * 
 */
  __pyx_r = (__pyx_v_self->log_sigma_sqrt_2_pi - (pow((__pyx_v_symbol - __pyx_v_self->mu), 2.0) / __pyx_v_self->two_sigma_squared));
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":362
 * 		self.two_sigma_squared = 2 * std ** 2
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":368
 * 			self.two_sigma_squared
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""Sample from this normal distribution and return the value sampled."""
 * 		return random.normalvariate( self.mu, self.sigma )
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_18NormalDistribution_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_18NormalDistribution_2sample[] = "Sample from this normal distribution and return the value sampled.";
static PyObject *__pyx_pw_11pomegranate_13distributions_18NormalDistribution_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_18NormalDistribution_2sample(((struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_18NormalDistribution_2sample(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);

  /* "pomegranate/distributions.pyx":370
 * 	def sample( self ):
 * 		"""Sample from this normal distribution and return the value sampled."""
 * 		return random.normalvariate( self.mu, self.sigma )             # <<<<<<<<<<<<<<
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0, min_std=0.01 ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_normalvariate); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->mu); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->sigma); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_5) {
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":368
 * 			self.two_sigma_squared
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""Sample from this normal distribution and return the value sampled."""
 * 		return random.normalvariate( self.mu, self.sigma )
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.NormalDistribution.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":372
 * 		return random.normalvariate( self.mu, self.sigma )
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0, min_std=0.01 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_18NormalDistribution_5from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_18NormalDistribution_4from_sample[] = "\n\t\tSet the parameters of this Distribution to maximize the likelihood of \n\t\tthe given sample. Items holds some sort of sequence. If weights is \n\t\tspecified, it holds a sequence of value to weight each item by.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_18NormalDistribution_5from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  PyObject *__pyx_v_inertia = 0;
  PyObject *__pyx_v_min_std = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,&__pyx_n_s_inertia,&__pyx_n_s_min_std,0};
    PyObject* values[4] = {0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_float_0_0);
    values[3] = ((PyObject *)__pyx_float_0_01);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_min_std);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_inertia = values[2];
    __pyx_v_min_std = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_sample", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.NormalDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_18NormalDistribution_4from_sample(((struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights, __pyx_v_inertia, __pyx_v_min_std);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_18NormalDistribution_4from_sample(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia, PyObject *__pyx_v_min_std) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_sample", 0);

  /* "pomegranate/distributions.pyx":379
 * 		"""
 * 
 * 		if self.frozen:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_1 = (__pyx_v_self->__pyx_base.frozen != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":380
 * 
 * 		if self.frozen:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		self.summarize( items, weights )
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":379
 * 		"""
 * 
 * 		if self.frozen:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":382
 * 			return
 * 
 * 		self.summarize( items, weights )             # <<<<<<<<<<<<<<
 * 		self.from_summaries( inertia, min_std )
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_summarize); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_4) {
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  }
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_weights);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":383
 * 
 * 		self.summarize( items, weights )
 * 		self.from_summaries( inertia, min_std )             # <<<<<<<<<<<<<<
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_summaries); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_6) {
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
  }
  __Pyx_INCREF(__pyx_v_inertia);
  __Pyx_GIVEREF(__pyx_v_inertia);
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_inertia);
  __Pyx_INCREF(__pyx_v_min_std);
  __Pyx_GIVEREF(__pyx_v_min_std);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_min_std);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":372
 * 		return random.normalvariate( self.mu, self.sigma )
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0, min_std=0.01 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pomegranate.distributions.NormalDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":385
 * 		self.from_summaries( inertia, min_std )
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython function to get the MLE estimate for a Gaussian."""
 * 
 */

static void __pyx_f_11pomegranate_13distributions_18NormalDistribution__summarize(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self, double *__pyx_v_items, double *__pyx_v_weights, __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n) {
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_i;
  double __pyx_v_x_sum;
  double __pyx_v_x2_sum;
  double __pyx_v_w_sum;
  __Pyx_RefNannyDeclarations
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_1;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_summarize", 0);
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif

  /* "pomegranate/distributions.pyx":386
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 * 		"""Cython function to get the MLE estimate for a Gaussian."""             # <<<<<<<<<<<<<<
 * 
 * 		cdef SIZE_t i
 */
  /*try:*/ {

    /* "pomegranate/distributions.pyx":389
 * 
 * 		cdef SIZE_t i
 * 		cdef double x_sum = 0.0, x2_sum = 0.0, w_sum = 0.0             # <<<<<<<<<<<<<<
 * 
 * 		# Calculate sufficient statistics for an update.
 */
    __pyx_v_x_sum = 0.0;
    __pyx_v_x2_sum = 0.0;
    __pyx_v_w_sum = 0.0;

    /* "pomegranate/distributions.pyx":392
 * 
 * 		# Calculate sufficient statistics for an update.
 * 		for i in range(n):             # <<<<<<<<<<<<<<
 * 			w_sum += weights[i]
 * 			x_sum += weights[i] * items[i]
 */
    __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;

      /* "pomegranate/distributions.pyx":393
 * 		# Calculate sufficient statistics for an update.
 * 		for i in range(n):
 * 			w_sum += weights[i]             # <<<<<<<<<<<<<<
 * 			x_sum += weights[i] * items[i]
 * 			x2_sum += weights[i] * items[i] * items[i]
 */
      __pyx_v_w_sum = (__pyx_v_w_sum + (__pyx_v_weights[__pyx_v_i]));

      /* "pomegranate/distributions.pyx":394
 * 		for i in range(n):
 * 			w_sum += weights[i]
 * 			x_sum += weights[i] * items[i]             # <<<<<<<<<<<<<<
 * 			x2_sum += weights[i] * items[i] * items[i]
 * 
 */
      __pyx_v_x_sum = (__pyx_v_x_sum + ((__pyx_v_weights[__pyx_v_i]) * (__pyx_v_items[__pyx_v_i])));

      /* "pomegranate/distributions.pyx":395
 * 			w_sum += weights[i]
 * 			x_sum += weights[i] * items[i]
 * 			x2_sum += weights[i] * items[i] * items[i]             # <<<<<<<<<<<<<<
 * 
 * 		with gil:
 */
      __pyx_v_x2_sum = (__pyx_v_x2_sum + (((__pyx_v_weights[__pyx_v_i]) * (__pyx_v_items[__pyx_v_i])) * (__pyx_v_items[__pyx_v_i])));
    }

    /* "pomegranate/distributions.pyx":397
 * 			x2_sum += weights[i] * items[i] * items[i]
 * 
 * 		with gil:             # <<<<<<<<<<<<<<
 * 			self.summaries[0] += w_sum
 * 			self.summaries[1] += x_sum
 */
    {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        /*try:*/ {

          /* "pomegranate/distributions.pyx":398
 * 
 * 		with gil:
 * 			self.summaries[0] += w_sum             # <<<<<<<<<<<<<<
 * 			self.summaries[1] += x_sum
 * 			self.summaries[2] += x2_sum
 */
          if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          __Pyx_INCREF(__pyx_v_self->__pyx_base.summaries);
          __pyx_t_3 = __pyx_v_self->__pyx_base.summaries;
          __pyx_t_4 = 0;
          if (unlikely(__pyx_t_3 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_t_3, __pyx_t_4, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L9_error;};
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_6 = PyFloat_FromDouble(__pyx_v_w_sum); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(__pyx_t_3 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          if (unlikely(__Pyx_SetItemInt(__pyx_t_3, __pyx_t_4, __pyx_t_7, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "pomegranate/distributions.pyx":399
 * 		with gil:
 * 			self.summaries[0] += w_sum
 * 			self.summaries[1] += x_sum             # <<<<<<<<<<<<<<
 * 			self.summaries[2] += x2_sum
 * 
 */
          if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          __Pyx_INCREF(__pyx_v_self->__pyx_base.summaries);
          __pyx_t_3 = __pyx_v_self->__pyx_base.summaries;
          __pyx_t_4 = 1;
          if (unlikely(__pyx_t_3 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_t_3, __pyx_t_4, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L9_error;};
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_6 = PyFloat_FromDouble(__pyx_v_x_sum); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(__pyx_t_3 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          if (unlikely(__Pyx_SetItemInt(__pyx_t_3, __pyx_t_4, __pyx_t_5, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "pomegranate/distributions.pyx":400
 * 			self.summaries[0] += w_sum
 * 			self.summaries[1] += x_sum
 * 			self.summaries[2] += x2_sum             # <<<<<<<<<<<<<<
 * 
 * 	def summarize( self, items, weights=None ):
 */
          if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          __Pyx_INCREF(__pyx_v_self->__pyx_base.summaries);
          __pyx_t_3 = __pyx_v_self->__pyx_base.summaries;
          __pyx_t_4 = 2;
          if (unlikely(__pyx_t_3 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_t_3, __pyx_t_4, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L9_error;};
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_6 = PyFloat_FromDouble(__pyx_v_x2_sum); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(__pyx_t_3 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          if (unlikely(__Pyx_SetItemInt(__pyx_t_3, __pyx_t_4, __pyx_t_7, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        }

        /* "pomegranate/distributions.pyx":397
 * 			x2_sum += weights[i] * items[i] * items[i]
 * 
 * 		with gil:             # <<<<<<<<<<<<<<
 * 			self.summaries[0] += w_sum
 * 			self.summaries[1] += x_sum
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            goto __pyx_L10;
          }
          __pyx_L9_error: {
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            goto __pyx_L4_error;
          }
          __pyx_L10:;
        }
    }
  }

  /* "pomegranate/distributions.pyx":386
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 * 		"""Cython function to get the MLE estimate for a Gaussian."""             # <<<<<<<<<<<<<<
 * 
 * 		cdef SIZE_t i
 */
  /*finally:*/ {
    /*normal exit:*/{
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L5;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "pomegranate/distributions.pyx":385
 * 		self.from_summaries( inertia, min_std )
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython function to get the MLE estimate for a Gaussian."""
 * 
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("pomegranate.distributions.NormalDistribution._summarize", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 1);
  __pyx_L0:;
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
}

/* "pomegranate/distributions.pyx":402
 * 			self.summaries[2] += x2_sum
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in a series of items and their weights and reduce it down to a
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_18NormalDistribution_7summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_18NormalDistribution_6summarize[] = "\n\t\tTake in a series of items and their weights and reduce it down to a\n\t\tsummary statistic to be used in training later.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_18NormalDistribution_7summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("summarize (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "summarize") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("summarize", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.NormalDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_18NormalDistribution_6summarize(((struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_18NormalDistribution_6summarize(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights) {
  double *__pyx_v_items_p;
  double *__pyx_v_weights_p;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  int __pyx_t_7;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("summarize", 0);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":408
 * 		"""
 * 
 * 		items, weights = weight_set( items, weights )             # <<<<<<<<<<<<<<
 * 		if weights.sum() <= 0:
 * 			return
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_weight_set); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_3) {
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  }
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_weights);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_5 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __Pyx_DECREF_SET(__pyx_v_items, __pyx_t_2);
  __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":409
 * 
 * 		items, weights = weight_set( items, weights )
 * 		if weights.sum() <= 0:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_weights, __pyx_n_s_sum); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_7) {

    /* "pomegranate/distributions.pyx":410
 * 		items, weights = weight_set( items, weights )
 * 		if weights.sum() <= 0:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":409
 * 
 * 		items, weights = weight_set( items, weights )
 * 		if weights.sum() <= 0:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":412
 * 			return
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data             # <<<<<<<<<<<<<<
 * 		cdef double* weights_p = <double*> (<numpy.ndarray> weights).data
 * 		cdef SIZE_t n = items.shape[0]
 */
  __pyx_v_items_p = ((double *)((PyArrayObject *)__pyx_v_items)->data);

  /* "pomegranate/distributions.pyx":413
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 * 		cdef double* weights_p = <double*> (<numpy.ndarray> weights).data             # <<<<<<<<<<<<<<
 * 		cdef SIZE_t n = items.shape[0]
 * 
 */
  __pyx_v_weights_p = ((double *)((PyArrayObject *)__pyx_v_weights)->data);

  /* "pomegranate/distributions.pyx":414
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 * 		cdef double* weights_p = <double*> (<numpy.ndarray> weights).data
 * 		cdef SIZE_t n = items.shape[0]             # <<<<<<<<<<<<<<
 * 
 * 		with nogil:
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_items, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_8 = __Pyx_PyInt_As_Py_intptr_t(__pyx_t_1); if (unlikely((__pyx_t_8 == (npy_intp)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_8;

  /* "pomegranate/distributions.pyx":416
 * 		cdef SIZE_t n = items.shape[0]
 * 
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			self._summarize( items_p, weights_p, n )
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "pomegranate/distributions.pyx":417
 * 
 * 		with nogil:
 * 			self._summarize( items_p, weights_p, n )             # <<<<<<<<<<<<<<
 * 
 * 	def from_summaries( self, inertia=0.0, min_std=0.01 ):
 */
        ((struct __pyx_vtabstruct_11pomegranate_13distributions_NormalDistribution *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._summarize(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), __pyx_v_items_p, __pyx_v_weights_p, __pyx_v_n);
      }

      /* "pomegranate/distributions.pyx":416
 * 		cdef SIZE_t n = items.shape[0]
 * 
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			self._summarize( items_p, weights_p, n )
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L8;
        }
        __pyx_L8:;
      }
  }

  /* "pomegranate/distributions.pyx":402
 * 			self.summaries[2] += x2_sum
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in a series of items and their weights and reduce it down to a
 */

  /* function exit code */
  __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_5);
  __Pyx_AddTraceback("pomegranate.distributions.NormalDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":419
 * 			self._summarize( items_p, weights_p, n )
 * 
 * 	def from_summaries( self, inertia=0.0, min_std=0.01 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Takes in a series of summaries, represented as a mean, a variance, and
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_18NormalDistribution_9from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_18NormalDistribution_8from_summaries[] = "\n\t\tTakes in a series of summaries, represented as a mean, a variance, and\n\t\ta weight, and updates the underlying distribution. Notes on how to do\n\t\tthis for a Gaussian distribution were taken from here:\n\t\thttp://math.stackexchange.com/questions/453113/how-to-merge-two-gaussians\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_18NormalDistribution_9from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_inertia = 0;
  PyObject *__pyx_v_min_std = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_summaries (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_inertia,&__pyx_n_s_min_std,0};
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject *)__pyx_float_0_0);
    values[1] = ((PyObject *)__pyx_float_0_01);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_min_std);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_summaries") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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;
      }
    }
    __pyx_v_inertia = values[0];
    __pyx_v_min_std = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_summaries", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.NormalDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_18NormalDistribution_8from_summaries(((struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *)__pyx_v_self), __pyx_v_inertia, __pyx_v_min_std);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_18NormalDistribution_8from_summaries(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *__pyx_v_self, PyObject *__pyx_v_inertia, PyObject *__pyx_v_min_std) {
  PyObject *__pyx_v_mu = NULL;
  PyObject *__pyx_v_var = NULL;
  PyObject *__pyx_v_sigma = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  double __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_summaries", 0);

  /* "pomegranate/distributions.pyx":428
 * 
 * 		# If no summaries stored or the summary is frozen, don't do anything.
 * 		if len( self.summaries ) == 0 or self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_2 = __pyx_v_self->__pyx_base.summaries;
  __Pyx_INCREF(__pyx_t_2);
  if (unlikely(__pyx_t_2 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = PyList_GET_SIZE(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = ((__pyx_t_3 == 0) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_self->__pyx_base.frozen == 1) != 0);
  __pyx_t_1 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":429
 * 		# If no summaries stored or the summary is frozen, don't do anything.
 * 		if len( self.summaries ) == 0 or self.frozen == True:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		mu = self.summaries[1] / self.summaries[0]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":428
 * 
 * 		# If no summaries stored or the summary is frozen, don't do anything.
 * 		if len( self.summaries ) == 0 or self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":431
 * 			return
 * 
 * 		mu = self.summaries[1] / self.summaries[0]             # <<<<<<<<<<<<<<
 * 		var = self.summaries[2] / self.summaries[0] - self.summaries[1] ** 2.0 / self.summaries[0] ** 2.0
 * 
 */
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_PyNumber_Divide(PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 1), PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_mu = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":432
 * 
 * 		mu = self.summaries[1] / self.summaries[0]
 * 		var = self.summaries[2] / self.summaries[0] - self.summaries[1] ** 2.0 / self.summaries[0] ** 2.0             # <<<<<<<<<<<<<<
 * 
 * 		sigma = csqrt(var)
 */
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_PyNumber_Divide(PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 2), PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = PyNumber_Power(PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 1), __pyx_float_2_0, Py_None); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = PyNumber_Power(PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 0), __pyx_float_2_0, Py_None); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyNumber_Divide(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Subtract(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_var = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "pomegranate/distributions.pyx":434
 * 		var = self.summaries[2] / self.summaries[0] - self.summaries[1] ** 2.0 / self.summaries[0] ** 2.0
 * 
 * 		sigma = csqrt(var)             # <<<<<<<<<<<<<<
 * 		if sigma < min_std:
 * 			sigma = min_std
 */
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_v_var); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = PyFloat_FromDouble(sqrt(__pyx_t_8)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_sigma = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "pomegranate/distributions.pyx":435
 * 
 * 		sigma = csqrt(var)
 * 		if sigma < min_std:             # <<<<<<<<<<<<<<
 * 			sigma = min_std
 * 
 */
  __pyx_t_6 = PyObject_RichCompare(__pyx_v_sigma, __pyx_v_min_std, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":436
 * 		sigma = csqrt(var)
 * 		if sigma < min_std:
 * 			sigma = min_std             # <<<<<<<<<<<<<<
 * 
 * 		self.mu = self.mu*inertia + mu*(1-inertia)
 */
    __Pyx_INCREF(__pyx_v_min_std);
    __Pyx_DECREF_SET(__pyx_v_sigma, __pyx_v_min_std);

    /* "pomegranate/distributions.pyx":435
 * 
 * 		sigma = csqrt(var)
 * 		if sigma < min_std:             # <<<<<<<<<<<<<<
 * 			sigma = min_std
 * 
 */
  }

  /* "pomegranate/distributions.pyx":438
 * 			sigma = min_std
 * 
 * 		self.mu = self.mu*inertia + mu*(1-inertia)             # <<<<<<<<<<<<<<
 * 		self.sigma = self.sigma*inertia + sigma*(1-inertia)
 * 		self.summaries = [0, 0, 0]
 */
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->mu); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyNumber_Multiply(__pyx_t_6, __pyx_v_inertia); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_inertia, 1, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = PyNumber_Multiply(__pyx_v_mu, __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Add(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_self->mu = __pyx_t_8;

  /* "pomegranate/distributions.pyx":439
 * 
 * 		self.mu = self.mu*inertia + mu*(1-inertia)
 * 		self.sigma = self.sigma*inertia + sigma*(1-inertia)             # <<<<<<<<<<<<<<
 * 		self.summaries = [0, 0, 0]
 * 		self.log_sigma_sqrt_2_pi = -_log(sigma * SQRT_2_PI)
 */
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->sigma); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = PyNumber_Multiply(__pyx_t_6, __pyx_v_inertia); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_inertia, 1, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyNumber_Multiply(__pyx_v_sigma, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Add(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_self->sigma = __pyx_t_8;

  /* "pomegranate/distributions.pyx":440
 * 		self.mu = self.mu*inertia + mu*(1-inertia)
 * 		self.sigma = self.sigma*inertia + sigma*(1-inertia)
 * 		self.summaries = [0, 0, 0]             # <<<<<<<<<<<<<<
 * 		self.log_sigma_sqrt_2_pi = -_log(sigma * SQRT_2_PI)
 * 		self.two_sigma_squared = 2 * sigma ** 2
 */
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_t_6);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.summaries);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.summaries);
  __pyx_v_self->__pyx_base.summaries = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "pomegranate/distributions.pyx":441
 * 		self.sigma = self.sigma*inertia + sigma*(1-inertia)
 * 		self.summaries = [0, 0, 0]
 * 		self.log_sigma_sqrt_2_pi = -_log(sigma * SQRT_2_PI)             # <<<<<<<<<<<<<<
 * 		self.two_sigma_squared = 2 * sigma ** 2
 * 
 */
  __pyx_t_6 = PyNumber_Multiply(__pyx_v_sigma, __pyx_float_2_50662827463); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_self->log_sigma_sqrt_2_pi = (-__pyx_f_11pomegranate_5utils__log(__pyx_t_8));

  /* "pomegranate/distributions.pyx":442
 * 		self.summaries = [0, 0, 0]
 * 		self.log_sigma_sqrt_2_pi = -_log(sigma * SQRT_2_PI)
 * 		self.two_sigma_squared = 2 * sigma ** 2             # <<<<<<<<<<<<<<
 * 
 * cdef class LogNormalDistribution( Distribution ):
 */
  __pyx_t_6 = PyNumber_Power(__pyx_v_sigma, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyNumber_Multiply(__pyx_int_2, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_7); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_self->two_sigma_squared = __pyx_t_8;

  /* "pomegranate/distributions.pyx":419
 * 			self._summarize( items_p, weights_p, n )
 * 
 * 	def from_summaries( self, inertia=0.0, min_std=0.01 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Takes in a series of summaries, represented as a mean, a variance, and
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.NormalDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_mu);
  __Pyx_XDECREF(__pyx_v_var);
  __Pyx_XDECREF(__pyx_v_sigma);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":450
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [self.mu, self.sigma]
 * 		def __set__( self, parameters ):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_10parameters_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_10parameters_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_10parameters___get__(((struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pomegranate/distributions.pyx":451
 * 	property parameters:
 * 		def __get__( self ):
 * 			return [self.mu, self.sigma]             # <<<<<<<<<<<<<<
 * 		def __set__( self, parameters ):
 * 			self.mu, self.sigma = parameters
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->mu); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->sigma); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":450
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [self.mu, self.sigma]
 * 		def __set__( self, parameters ):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.LogNormalDistribution.parameters.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":452
 * 		def __get__( self ):
 * 			return [self.mu, self.sigma]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.mu, self.sigma = parameters
 * 
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_10parameters_2__set__(((struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_parameters));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *(*__pyx_t_4)(PyObject *);
  double __pyx_t_5;
  double __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "pomegranate/distributions.pyx":453
 * 			return [self.mu, self.sigma]
 * 		def __set__( self, parameters ):
 * 			self.mu, self.sigma = parameters             # <<<<<<<<<<<<<<
 * 
 * 	def __cinit__( self, double mu, double sigma, frozen=False ):
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_parameters))) || (PyList_CheckExact(__pyx_v_parameters))) {
    PyObject* sequence = __pyx_v_parameters;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_v_parameters); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->mu = __pyx_t_5;
  __pyx_v_self->sigma = __pyx_t_6;

  /* "pomegranate/distributions.pyx":452
 * 		def __get__( self ):
 * 			return [self.mu, self.sigma]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.mu, self.sigma = parameters
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.LogNormalDistribution.parameters.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":455
 * 			self.mu, self.sigma = parameters
 * 
 * 	def __cinit__( self, double mu, double sigma, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Make a new lognormal distribution. The parameters are the mu and sigma
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_mu;
  double __pyx_v_sigma;
  PyObject *__pyx_v_frozen = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mu,&__pyx_n_s_sigma,&__pyx_n_s_frozen,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mu)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sigma)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_mu = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_mu == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_sigma = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_sigma == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_frozen = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.LogNormalDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21LogNormalDistribution___cinit__(((struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *)__pyx_v_self), __pyx_v_mu, __pyx_v_sigma, __pyx_v_frozen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_21LogNormalDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self, double __pyx_v_mu, double __pyx_v_sigma, PyObject *__pyx_v_frozen) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "pomegranate/distributions.pyx":462
 * 		"""
 * 
 * 		self.mu = mu             # <<<<<<<<<<<<<<
 * 		self.sigma = sigma
 * 		self.summaries = [0, 0, 0]
 */
  __pyx_v_self->mu = __pyx_v_mu;

  /* "pomegranate/distributions.pyx":463
 * 
 * 		self.mu = mu
 * 		self.sigma = sigma             # <<<<<<<<<<<<<<
 * 		self.summaries = [0, 0, 0]
 * 		self.name = "LogNormalDistribution"
 */
  __pyx_v_self->sigma = __pyx_v_sigma;

  /* "pomegranate/distributions.pyx":464
 * 		self.mu = mu
 * 		self.sigma = sigma
 * 		self.summaries = [0, 0, 0]             # <<<<<<<<<<<<<<
 * 		self.name = "LogNormalDistribution"
 * 		self.frozen = frozen
 */
  __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.summaries);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.summaries);
  __pyx_v_self->__pyx_base.summaries = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":465
 * 		self.sigma = sigma
 * 		self.summaries = [0, 0, 0]
 * 		self.name = "LogNormalDistribution"             # <<<<<<<<<<<<<<
 * 		self.frozen = frozen
 * 
 */
  __Pyx_INCREF(__pyx_n_s_LogNormalDistribution);
  __Pyx_GIVEREF(__pyx_n_s_LogNormalDistribution);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.name);
  __pyx_v_self->__pyx_base.name = __pyx_n_s_LogNormalDistribution;

  /* "pomegranate/distributions.pyx":466
 * 		self.summaries = [0, 0, 0]
 * 		self.name = "LogNormalDistribution"
 * 		self.frozen = frozen             # <<<<<<<<<<<<<<
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_frozen); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->__pyx_base.frozen = __pyx_t_2;

  /* "pomegranate/distributions.pyx":455
 * 			self.mu, self.sigma = parameters
 * 
 * 	def __cinit__( self, double mu, double sigma, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Make a new lognormal distribution. The parameters are the mu and sigma
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.LogNormalDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":468
 * 		self.frozen = frozen
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

static double __pyx_f_11pomegranate_13distributions_21LogNormalDistribution__log_probability(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self, double __pyx_v_symbol) {
  double __pyx_v_mu;
  double __pyx_v_sigma;
  double __pyx_r;
  double __pyx_t_1;

  /* "pomegranate/distributions.pyx":471
 * 		"""Cython optimized function for log probability calculation."""
 * 
 * 		cdef double mu = self.mu, sigma = self.sigma             # <<<<<<<<<<<<<<
 * 
 * 		return -_log( symbol * sigma * SQRT_2_PI ) \
 */
  __pyx_t_1 = __pyx_v_self->mu;
  __pyx_v_mu = __pyx_t_1;
  __pyx_t_1 = __pyx_v_self->sigma;
  __pyx_v_sigma = __pyx_t_1;

  /* "pomegranate/distributions.pyx":474
 * 
 * 		return -_log( symbol * sigma * SQRT_2_PI ) \
 * 			- 0.5 * ( ( _log( symbol ) - mu ) / sigma ) ** 2             # <<<<<<<<<<<<<<
 * 
 * 	def sample( self ):
 */
  __pyx_r = ((-__pyx_f_11pomegranate_5utils__log(((__pyx_v_symbol * __pyx_v_sigma) * 2.50662827463))) - (0.5 * pow(((__pyx_f_11pomegranate_5utils__log(__pyx_v_symbol) - __pyx_v_mu) / __pyx_v_sigma), 2.0)));
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":468
 * 		self.frozen = frozen
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":476
 * 			- 0.5 * ( ( _log( symbol ) - mu ) / sigma ) ** 2
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""Return a sample from this distribution."""
 * 		return numpy.random.lognormal( self.mu, self.sigma )
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_21LogNormalDistribution_2sample[] = "Return a sample from this distribution.";
static PyObject *__pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_2sample(((struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_2sample(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);

  /* "pomegranate/distributions.pyx":478
 * 	def sample( self ):
 * 		"""Return a sample from this distribution."""
 * 		return numpy.random.lognormal( self.mu, self.sigma )             # <<<<<<<<<<<<<<
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0, min_std=0.01 ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_lognormal); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->mu); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->sigma); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_5) {
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":476
 * 			- 0.5 * ( ( _log( symbol ) - mu ) / sigma ) ** 2
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""Return a sample from this distribution."""
 * 		return numpy.random.lognormal( self.mu, self.sigma )
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.LogNormalDistribution.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":480
 * 		return numpy.random.lognormal( self.mu, self.sigma )
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0, min_std=0.01 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_5from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_21LogNormalDistribution_4from_sample[] = "\n\t\tSet the parameters of this Distribution to maximize the likelihood of \n\t\tthe given sample. Items holds some sort of sequence. If weights is \n\t\tspecified, it holds a sequence of value to weight each item by.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_5from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  PyObject *__pyx_v_inertia = 0;
  PyObject *__pyx_v_min_std = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,&__pyx_n_s_inertia,&__pyx_n_s_min_std,0};
    PyObject* values[4] = {0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_float_0_0);
    values[3] = ((PyObject *)__pyx_float_0_01);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_min_std);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_inertia = values[2];
    __pyx_v_min_std = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_sample", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.LogNormalDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_4from_sample(((struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights, __pyx_v_inertia, __pyx_v_min_std);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_4from_sample(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia, PyObject *__pyx_v_min_std) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_sample", 0);

  /* "pomegranate/distributions.pyx":487
 * 		"""
 * 
 * 		if self.frozen:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_1 = (__pyx_v_self->__pyx_base.frozen != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":488
 * 
 * 		if self.frozen:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		self.summarize( items, weights )
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":487
 * 		"""
 * 
 * 		if self.frozen:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":490
 * 			return
 * 
 * 		self.summarize( items, weights )             # <<<<<<<<<<<<<<
 * 		self.from_summaries( inertia, min_std )
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_summarize); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_4) {
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  }
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_weights);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":491
 * 
 * 		self.summarize( items, weights )
 * 		self.from_summaries( inertia, min_std )             # <<<<<<<<<<<<<<
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_summaries); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_6) {
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
  }
  __Pyx_INCREF(__pyx_v_inertia);
  __Pyx_GIVEREF(__pyx_v_inertia);
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_inertia);
  __Pyx_INCREF(__pyx_v_min_std);
  __Pyx_GIVEREF(__pyx_v_min_std);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_min_std);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":480
 * 		return numpy.random.lognormal( self.mu, self.sigma )
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0, min_std=0.01 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pomegranate.distributions.LogNormalDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":493
 * 		self.from_summaries( inertia, min_std )
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython function to get the MLE estimate for a Gaussian."""
 * 
 */

static void __pyx_f_11pomegranate_13distributions_21LogNormalDistribution__summarize(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self, double *__pyx_v_items, double *__pyx_v_weights, __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n) {
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_i;
  double __pyx_v_x_sum;
  double __pyx_v_x2_sum;
  double __pyx_v_w_sum;
  double __pyx_v_log_item;
  __Pyx_RefNannyDeclarations
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_1;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_summarize", 0);
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif

  /* "pomegranate/distributions.pyx":494
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 * 		"""Cython function to get the MLE estimate for a Gaussian."""             # <<<<<<<<<<<<<<
 * 
 * 		cdef SIZE_t i
 */
  /*try:*/ {

    /* "pomegranate/distributions.pyx":497
 * 
 * 		cdef SIZE_t i
 * 		cdef double x_sum = 0.0, x2_sum = 0.0, w_sum = 0.0             # <<<<<<<<<<<<<<
 * 		cdef double log_item
 * 
 */
    __pyx_v_x_sum = 0.0;
    __pyx_v_x2_sum = 0.0;
    __pyx_v_w_sum = 0.0;

    /* "pomegranate/distributions.pyx":501
 * 
 * 		# Calculate the average, which is the MLE mu estimate
 * 		for i in range(n):             # <<<<<<<<<<<<<<
 * 			log_item = _log(items[i])
 * 			w_sum += weights[i]
 */
    __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;

      /* "pomegranate/distributions.pyx":502
 * 		# Calculate the average, which is the MLE mu estimate
 * 		for i in range(n):
 * 			log_item = _log(items[i])             # <<<<<<<<<<<<<<
 * 			w_sum += weights[i]
 * 			x_sum += weights[i] * log_item
 */
      __pyx_v_log_item = __pyx_f_11pomegranate_5utils__log((__pyx_v_items[__pyx_v_i]));

      /* "pomegranate/distributions.pyx":503
 * 		for i in range(n):
 * 			log_item = _log(items[i])
 * 			w_sum += weights[i]             # <<<<<<<<<<<<<<
 * 			x_sum += weights[i] * log_item
 * 			x2_sum += weights[i] * log_item * log_item
 */
      __pyx_v_w_sum = (__pyx_v_w_sum + (__pyx_v_weights[__pyx_v_i]));

      /* "pomegranate/distributions.pyx":504
 * 			log_item = _log(items[i])
 * 			w_sum += weights[i]
 * 			x_sum += weights[i] * log_item             # <<<<<<<<<<<<<<
 * 			x2_sum += weights[i] * log_item * log_item
 * 
 */
      __pyx_v_x_sum = (__pyx_v_x_sum + ((__pyx_v_weights[__pyx_v_i]) * __pyx_v_log_item));

      /* "pomegranate/distributions.pyx":505
 * 			w_sum += weights[i]
 * 			x_sum += weights[i] * log_item
 * 			x2_sum += weights[i] * log_item * log_item             # <<<<<<<<<<<<<<
 * 
 * 		with gil:
 */
      __pyx_v_x2_sum = (__pyx_v_x2_sum + (((__pyx_v_weights[__pyx_v_i]) * __pyx_v_log_item) * __pyx_v_log_item));
    }

    /* "pomegranate/distributions.pyx":507
 * 			x2_sum += weights[i] * log_item * log_item
 * 
 * 		with gil:             # <<<<<<<<<<<<<<
 * 			self.summaries[0] += w_sum
 * 			self.summaries[1] += x_sum
 */
    {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        /*try:*/ {

          /* "pomegranate/distributions.pyx":508
 * 
 * 		with gil:
 * 			self.summaries[0] += w_sum             # <<<<<<<<<<<<<<
 * 			self.summaries[1] += x_sum
 * 			self.summaries[2] += x2_sum
 */
          if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          __Pyx_INCREF(__pyx_v_self->__pyx_base.summaries);
          __pyx_t_3 = __pyx_v_self->__pyx_base.summaries;
          __pyx_t_4 = 0;
          if (unlikely(__pyx_t_3 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_t_3, __pyx_t_4, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L9_error;};
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_6 = PyFloat_FromDouble(__pyx_v_w_sum); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(__pyx_t_3 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          if (unlikely(__Pyx_SetItemInt(__pyx_t_3, __pyx_t_4, __pyx_t_7, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "pomegranate/distributions.pyx":509
 * 		with gil:
 * 			self.summaries[0] += w_sum
 * 			self.summaries[1] += x_sum             # <<<<<<<<<<<<<<
 * 			self.summaries[2] += x2_sum
 * 
 */
          if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          __Pyx_INCREF(__pyx_v_self->__pyx_base.summaries);
          __pyx_t_3 = __pyx_v_self->__pyx_base.summaries;
          __pyx_t_4 = 1;
          if (unlikely(__pyx_t_3 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_t_3, __pyx_t_4, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L9_error;};
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_6 = PyFloat_FromDouble(__pyx_v_x_sum); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(__pyx_t_3 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          if (unlikely(__Pyx_SetItemInt(__pyx_t_3, __pyx_t_4, __pyx_t_5, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "pomegranate/distributions.pyx":510
 * 			self.summaries[0] += w_sum
 * 			self.summaries[1] += x_sum
 * 			self.summaries[2] += x2_sum             # <<<<<<<<<<<<<<
 * 
 * 	def summarize( self, items, weights=None ):
 */
          if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          __Pyx_INCREF(__pyx_v_self->__pyx_base.summaries);
          __pyx_t_3 = __pyx_v_self->__pyx_base.summaries;
          __pyx_t_4 = 2;
          if (unlikely(__pyx_t_3 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_t_3, __pyx_t_4, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L9_error;};
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_6 = PyFloat_FromDouble(__pyx_v_x2_sum); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(__pyx_t_3 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          if (unlikely(__Pyx_SetItemInt(__pyx_t_3, __pyx_t_4, __pyx_t_7, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        }

        /* "pomegranate/distributions.pyx":507
 * 			x2_sum += weights[i] * log_item * log_item
 * 
 * 		with gil:             # <<<<<<<<<<<<<<
 * 			self.summaries[0] += w_sum
 * 			self.summaries[1] += x_sum
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            goto __pyx_L10;
          }
          __pyx_L9_error: {
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            goto __pyx_L4_error;
          }
          __pyx_L10:;
        }
    }
  }

  /* "pomegranate/distributions.pyx":494
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 * 		"""Cython function to get the MLE estimate for a Gaussian."""             # <<<<<<<<<<<<<<
 * 
 * 		cdef SIZE_t i
 */
  /*finally:*/ {
    /*normal exit:*/{
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L5;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "pomegranate/distributions.pyx":493
 * 		self.from_summaries( inertia, min_std )
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython function to get the MLE estimate for a Gaussian."""
 * 
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("pomegranate.distributions.LogNormalDistribution._summarize", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 1);
  __pyx_L0:;
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
}

/* "pomegranate/distributions.pyx":512
 * 			self.summaries[2] += x2_sum
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in a series of items and their weights and reduce it down to a
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_7summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_21LogNormalDistribution_6summarize[] = "\n\t\tTake in a series of items and their weights and reduce it down to a\n\t\tsummary statistic to be used in training later.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_7summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("summarize (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "summarize") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("summarize", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.LogNormalDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_6summarize(((struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_6summarize(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights) {
  double *__pyx_v_items_p;
  double *__pyx_v_weights_p;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  int __pyx_t_7;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("summarize", 0);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":518
 * 		"""
 * 
 * 		items, weights = weight_set( items, weights )             # <<<<<<<<<<<<<<
 * 		if weights.sum() <= 0:
 * 			return
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_weight_set); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_3) {
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  }
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_weights);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_5 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __Pyx_DECREF_SET(__pyx_v_items, __pyx_t_2);
  __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":519
 * 
 * 		items, weights = weight_set( items, weights )
 * 		if weights.sum() <= 0:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_weights, __pyx_n_s_sum); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_7) {

    /* "pomegranate/distributions.pyx":520
 * 		items, weights = weight_set( items, weights )
 * 		if weights.sum() <= 0:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":519
 * 
 * 		items, weights = weight_set( items, weights )
 * 		if weights.sum() <= 0:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":522
 * 			return
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data             # <<<<<<<<<<<<<<
 * 		cdef double* weights_p = <double*> (<numpy.ndarray> weights).data
 * 		cdef SIZE_t n = items.shape[0]
 */
  __pyx_v_items_p = ((double *)((PyArrayObject *)__pyx_v_items)->data);

  /* "pomegranate/distributions.pyx":523
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 * 		cdef double* weights_p = <double*> (<numpy.ndarray> weights).data             # <<<<<<<<<<<<<<
 * 		cdef SIZE_t n = items.shape[0]
 * 
 */
  __pyx_v_weights_p = ((double *)((PyArrayObject *)__pyx_v_weights)->data);

  /* "pomegranate/distributions.pyx":524
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 * 		cdef double* weights_p = <double*> (<numpy.ndarray> weights).data
 * 		cdef SIZE_t n = items.shape[0]             # <<<<<<<<<<<<<<
 * 
 * 		with nogil:
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_items, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_8 = __Pyx_PyInt_As_Py_intptr_t(__pyx_t_1); if (unlikely((__pyx_t_8 == (npy_intp)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_8;

  /* "pomegranate/distributions.pyx":526
 * 		cdef SIZE_t n = items.shape[0]
 * 
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			self._summarize( items_p, weights_p, n )
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "pomegranate/distributions.pyx":527
 * 
 * 		with nogil:
 * 			self._summarize( items_p, weights_p, n )             # <<<<<<<<<<<<<<
 * 
 * 	def from_summaries( self, inertia=0.0, min_std=0.01 ):
 */
        ((struct __pyx_vtabstruct_11pomegranate_13distributions_LogNormalDistribution *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._summarize(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), __pyx_v_items_p, __pyx_v_weights_p, __pyx_v_n);
      }

      /* "pomegranate/distributions.pyx":526
 * 		cdef SIZE_t n = items.shape[0]
 * 
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			self._summarize( items_p, weights_p, n )
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L8;
        }
        __pyx_L8:;
      }
  }

  /* "pomegranate/distributions.pyx":512
 * 			self.summaries[2] += x2_sum
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in a series of items and their weights and reduce it down to a
 */

  /* function exit code */
  __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_5);
  __Pyx_AddTraceback("pomegranate.distributions.LogNormalDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":529
 * 			self._summarize( items_p, weights_p, n )
 * 
 * 	def from_summaries( self, inertia=0.0, min_std=0.01 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Takes in a series of summaries, represented as a mean, a variance, and
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_9from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_21LogNormalDistribution_8from_summaries[] = "\n\t\tTakes in a series of summaries, represented as a mean, a variance, and\n\t\ta weight, and updates the underlying distribution. Notes on how to do\n\t\tthis for a Gaussian distribution were taken from here:\n\t\thttp://math.stackexchange.com/questions/453113/how-to-merge-two-gaussians\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_9from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_inertia = 0;
  PyObject *__pyx_v_min_std = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_summaries (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_inertia,&__pyx_n_s_min_std,0};
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject *)__pyx_float_0_0);
    values[1] = ((PyObject *)__pyx_float_0_01);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_min_std);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_summaries") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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;
      }
    }
    __pyx_v_inertia = values[0];
    __pyx_v_min_std = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_summaries", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.LogNormalDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_8from_summaries(((struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *)__pyx_v_self), __pyx_v_inertia, __pyx_v_min_std);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_21LogNormalDistribution_8from_summaries(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *__pyx_v_self, PyObject *__pyx_v_inertia, PyObject *__pyx_v_min_std) {
  PyObject *__pyx_v_mu = NULL;
  PyObject *__pyx_v_var = NULL;
  PyObject *__pyx_v_sigma = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  double __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_summaries", 0);

  /* "pomegranate/distributions.pyx":538
 * 
 * 		# If no summaries stored or the summary is frozen, don't do anything.
 * 		if len( self.summaries ) == 0 or self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_2 = __pyx_v_self->__pyx_base.summaries;
  __Pyx_INCREF(__pyx_t_2);
  if (unlikely(__pyx_t_2 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = PyList_GET_SIZE(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = ((__pyx_t_3 == 0) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_self->__pyx_base.frozen == 1) != 0);
  __pyx_t_1 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":539
 * 		# If no summaries stored or the summary is frozen, don't do anything.
 * 		if len( self.summaries ) == 0 or self.frozen == True:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		mu = self.summaries[1] / self.summaries[0]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":538
 * 
 * 		# If no summaries stored or the summary is frozen, don't do anything.
 * 		if len( self.summaries ) == 0 or self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":541
 * 			return
 * 
 * 		mu = self.summaries[1] / self.summaries[0]             # <<<<<<<<<<<<<<
 * 		var = self.summaries[2] / self.summaries[0] - self.summaries[1] ** 2.0 / self.summaries[0] ** 2.0
 * 
 */
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_PyNumber_Divide(PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 1), PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_mu = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":542
 * 
 * 		mu = self.summaries[1] / self.summaries[0]
 * 		var = self.summaries[2] / self.summaries[0] - self.summaries[1] ** 2.0 / self.summaries[0] ** 2.0             # <<<<<<<<<<<<<<
 * 
 * 		sigma = csqrt(var)
 */
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_PyNumber_Divide(PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 2), PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = PyNumber_Power(PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 1), __pyx_float_2_0, Py_None); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = PyNumber_Power(PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 0), __pyx_float_2_0, Py_None); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyNumber_Divide(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Subtract(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_var = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "pomegranate/distributions.pyx":544
 * 		var = self.summaries[2] / self.summaries[0] - self.summaries[1] ** 2.0 / self.summaries[0] ** 2.0
 * 
 * 		sigma = csqrt(var)             # <<<<<<<<<<<<<<
 * 		if sigma < min_std:
 * 			sigma = min_std
 */
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_v_var); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = PyFloat_FromDouble(sqrt(__pyx_t_8)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_sigma = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "pomegranate/distributions.pyx":545
 * 
 * 		sigma = csqrt(var)
 * 		if sigma < min_std:             # <<<<<<<<<<<<<<
 * 			sigma = min_std
 * 
 */
  __pyx_t_6 = PyObject_RichCompare(__pyx_v_sigma, __pyx_v_min_std, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":546
 * 		sigma = csqrt(var)
 * 		if sigma < min_std:
 * 			sigma = min_std             # <<<<<<<<<<<<<<
 * 
 * 		self.mu = self.mu*inertia + mu*(1-inertia)
 */
    __Pyx_INCREF(__pyx_v_min_std);
    __Pyx_DECREF_SET(__pyx_v_sigma, __pyx_v_min_std);

    /* "pomegranate/distributions.pyx":545
 * 
 * 		sigma = csqrt(var)
 * 		if sigma < min_std:             # <<<<<<<<<<<<<<
 * 			sigma = min_std
 * 
 */
  }

  /* "pomegranate/distributions.pyx":548
 * 			sigma = min_std
 * 
 * 		self.mu = self.mu*inertia + mu*(1-inertia)             # <<<<<<<<<<<<<<
 * 		self.sigma = self.sigma*inertia + sigma*(1-inertia)
 * 		self.summaries = [0, 0, 0]
 */
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->mu); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyNumber_Multiply(__pyx_t_6, __pyx_v_inertia); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_inertia, 1, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = PyNumber_Multiply(__pyx_v_mu, __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Add(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_self->mu = __pyx_t_8;

  /* "pomegranate/distributions.pyx":549
 * 
 * 		self.mu = self.mu*inertia + mu*(1-inertia)
 * 		self.sigma = self.sigma*inertia + sigma*(1-inertia)             # <<<<<<<<<<<<<<
 * 		self.summaries = [0, 0, 0]
 * 
 */
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->sigma); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = PyNumber_Multiply(__pyx_t_6, __pyx_v_inertia); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_inertia, 1, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyNumber_Multiply(__pyx_v_sigma, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Add(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_self->sigma = __pyx_t_8;

  /* "pomegranate/distributions.pyx":550
 * 		self.mu = self.mu*inertia + mu*(1-inertia)
 * 		self.sigma = self.sigma*inertia + sigma*(1-inertia)
 * 		self.summaries = [0, 0, 0]             # <<<<<<<<<<<<<<
 * 
 * cdef class ExponentialDistribution( Distribution ):
 */
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_t_6);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.summaries);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.summaries);
  __pyx_v_self->__pyx_base.summaries = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "pomegranate/distributions.pyx":529
 * 			self._summarize( items_p, weights_p, n )
 * 
 * 	def from_summaries( self, inertia=0.0, min_std=0.01 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Takes in a series of summaries, represented as a mean, a variance, and
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.LogNormalDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_mu);
  __Pyx_XDECREF(__pyx_v_var);
  __Pyx_XDECREF(__pyx_v_sigma);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":558
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [ self.rate ]
 * 		def __set__( self, parameters ):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_10parameters_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_10parameters_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_10parameters___get__(((struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pomegranate/distributions.pyx":559
 * 	property parameters:
 * 		def __get__( self ):
 * 			return [ self.rate ]             # <<<<<<<<<<<<<<
 * 		def __set__( self, parameters ):
 * 			self.rate = parameters[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->rate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":558
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [ self.rate ]
 * 		def __set__( self, parameters ):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pomegranate.distributions.ExponentialDistribution.parameters.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":560
 * 		def __get__( self ):
 * 			return [ self.rate ]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.rate = parameters[0]
 * 
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_10parameters_2__set__(((struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_parameters));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  double __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "pomegranate/distributions.pyx":561
 * 			return [ self.rate ]
 * 		def __set__( self, parameters ):
 * 			self.rate = parameters[0]             # <<<<<<<<<<<<<<
 * 
 * 	def __cinit__( self, double rate, bint frozen=False ):
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_parameters, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->rate = __pyx_t_2;

  /* "pomegranate/distributions.pyx":560
 * 		def __get__( self ):
 * 			return [ self.rate ]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.rate = parameters[0]
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.ExponentialDistribution.parameters.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":563
 * 			self.rate = parameters[0]
 * 
 * 	def __cinit__( self, double rate, bint frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Make a new inverse gamma distribution. The parameter is called "rate"
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_rate;
  int __pyx_v_frozen;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_rate,&__pyx_n_s_frozen,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_rate)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_rate = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_rate == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[1]) {
      __pyx_v_frozen = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_frozen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_frozen = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.ExponentialDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_23ExponentialDistribution___cinit__(((struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *)__pyx_v_self), __pyx_v_rate, __pyx_v_frozen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_23ExponentialDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self, double __pyx_v_rate, int __pyx_v_frozen) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "pomegranate/distributions.pyx":569
 * 		"""
 * 
 * 		self.rate = rate             # <<<<<<<<<<<<<<
 * 		self.summaries = [0, 0]
 * 		self.name = "ExponentialDistribution"
 */
  __pyx_v_self->rate = __pyx_v_rate;

  /* "pomegranate/distributions.pyx":570
 * 
 * 		self.rate = rate
 * 		self.summaries = [0, 0]             # <<<<<<<<<<<<<<
 * 		self.name = "ExponentialDistribution"
 * 		self.frozen = frozen
 */
  __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.summaries);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.summaries);
  __pyx_v_self->__pyx_base.summaries = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":571
 * 		self.rate = rate
 * 		self.summaries = [0, 0]
 * 		self.name = "ExponentialDistribution"             # <<<<<<<<<<<<<<
 * 		self.frozen = frozen
 * 
 */
  __Pyx_INCREF(__pyx_n_s_ExponentialDistribution);
  __Pyx_GIVEREF(__pyx_n_s_ExponentialDistribution);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.name);
  __pyx_v_self->__pyx_base.name = __pyx_n_s_ExponentialDistribution;

  /* "pomegranate/distributions.pyx":572
 * 		self.summaries = [0, 0]
 * 		self.name = "ExponentialDistribution"
 * 		self.frozen = frozen             # <<<<<<<<<<<<<<
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:
 */
  __pyx_v_self->__pyx_base.frozen = __pyx_v_frozen;

  /* "pomegranate/distributions.pyx":563
 * 			self.rate = parameters[0]
 * 
 * 	def __cinit__( self, double rate, bint frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Make a new inverse gamma distribution. The parameter is called "rate"
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.ExponentialDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":574
 * 		self.frozen = frozen
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 		return _log(self.rate) - self.rate * symbol
 */

static double __pyx_f_11pomegranate_13distributions_23ExponentialDistribution__log_probability(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self, double __pyx_v_symbol) {
  double __pyx_r;

  /* "pomegranate/distributions.pyx":576
 * 	cdef double _log_probability( self, double symbol ) nogil:
 * 		"""Cython optimized function for log probability calculation."""
 * 		return _log(self.rate) - self.rate * symbol             # <<<<<<<<<<<<<<
 * 
 * 	def sample( self ):
 */
  __pyx_r = (__pyx_f_11pomegranate_5utils__log(__pyx_v_self->rate) - (__pyx_v_self->rate * __pyx_v_symbol));
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":574
 * 		self.frozen = frozen
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 		return _log(self.rate) - self.rate * symbol
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":578
 * 		return _log(self.rate) - self.rate * symbol
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""Sample from this exponential distribution."""
 * 		return random.expovariate(*self.parameters)
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_23ExponentialDistribution_2sample[] = "Sample from this exponential distribution.";
static PyObject *__pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_2sample(((struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_2sample(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);

  /* "pomegranate/distributions.pyx":580
 * 	def sample( self ):
 * 		"""Sample from this exponential distribution."""
 * 		return random.expovariate(*self.parameters)             # <<<<<<<<<<<<<<
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0 ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_expovariate); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":578
 * 		return _log(self.rate) - self.rate * symbol
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""Sample from this exponential distribution."""
 * 		return random.expovariate(*self.parameters)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.ExponentialDistribution.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":582
 * 		return random.expovariate(*self.parameters)
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_5from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_23ExponentialDistribution_4from_sample[] = "\n\t\tSet the parameters of this Distribution to maximize the likelihood of \n\t\tthe given sample. Items holds some sort of sequence. If weights is \n\t\tspecified, it holds a sequence of value to weight each item by.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_5from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,&__pyx_n_s_inertia,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_inertia = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_sample", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.ExponentialDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_4from_sample(((struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights, __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_4from_sample(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_sample", 0);

  /* "pomegranate/distributions.pyx":589
 * 		"""
 * 
 * 		if self.frozen:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_1 = (__pyx_v_self->__pyx_base.frozen != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":590
 * 
 * 		if self.frozen:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		self.summarize( items, weights )
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":589
 * 		"""
 * 
 * 		if self.frozen:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":592
 * 			return
 * 
 * 		self.summarize( items, weights )             # <<<<<<<<<<<<<<
 * 		self.from_summaries( inertia )
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_summarize); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_4) {
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  }
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_weights);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":593
 * 
 * 		self.summarize( items, weights )
 * 		self.from_summaries( inertia )             # <<<<<<<<<<<<<<
 * 
 * 	def summarize( self, items, weights=None ):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_summaries); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_inertia); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_INCREF(__pyx_v_inertia);
    __Pyx_GIVEREF(__pyx_v_inertia);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_inertia);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":582
 * 		return random.expovariate(*self.parameters)
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pomegranate.distributions.ExponentialDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":595
 * 		self.from_summaries( inertia )
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in a series of items and their weights and reduce it down to a
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_7summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_23ExponentialDistribution_6summarize[] = "\n\t\tTake in a series of items and their weights and reduce it down to a\n\t\tsummary statistic to be used in training later.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_7summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("summarize (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "summarize") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("summarize", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.ExponentialDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_6summarize(((struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_6summarize(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights) {
  double *__pyx_v_items_p;
  double *__pyx_v_weights_p;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("summarize", 0);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":601
 * 		"""
 * 
 * 		items, weights = weight_set( items, weights )             # <<<<<<<<<<<<<<
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_weight_set); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_3) {
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  }
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_weights);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_5 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __Pyx_DECREF_SET(__pyx_v_items, __pyx_t_2);
  __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":603
 * 		items, weights = weight_set( items, weights )
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data             # <<<<<<<<<<<<<<
 * 		cdef double* weights_p = <double*> (<numpy.ndarray> weights).data
 * 		cdef SIZE_t n = items.shape[0]
 */
  __pyx_v_items_p = ((double *)((PyArrayObject *)__pyx_v_items)->data);

  /* "pomegranate/distributions.pyx":604
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 * 		cdef double* weights_p = <double*> (<numpy.ndarray> weights).data             # <<<<<<<<<<<<<<
 * 		cdef SIZE_t n = items.shape[0]
 * 
 */
  __pyx_v_weights_p = ((double *)((PyArrayObject *)__pyx_v_weights)->data);

  /* "pomegranate/distributions.pyx":605
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 * 		cdef double* weights_p = <double*> (<numpy.ndarray> weights).data
 * 		cdef SIZE_t n = items.shape[0]             # <<<<<<<<<<<<<<
 * 
 * 		with nogil:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_items, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_Py_intptr_t(__pyx_t_5); if (unlikely((__pyx_t_7 == (npy_intp)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_n = __pyx_t_7;

  /* "pomegranate/distributions.pyx":607
 * 		cdef SIZE_t n = items.shape[0]
 * 
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			self._summarize( items_p, weights_p, n )
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "pomegranate/distributions.pyx":608
 * 
 * 		with nogil:
 * 			self._summarize( items_p, weights_p, n )             # <<<<<<<<<<<<<<
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 */
        ((struct __pyx_vtabstruct_11pomegranate_13distributions_ExponentialDistribution *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._summarize(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), __pyx_v_items_p, __pyx_v_weights_p, __pyx_v_n);
      }

      /* "pomegranate/distributions.pyx":607
 * 		cdef SIZE_t n = items.shape[0]
 * 
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			self._summarize( items_p, weights_p, n )
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L7;
        }
        __pyx_L7:;
      }
  }

  /* "pomegranate/distributions.pyx":595
 * 		self.from_summaries( inertia )
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in a series of items and their weights and reduce it down to a
 */

  /* function exit code */
  __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_5);
  __Pyx_AddTraceback("pomegranate.distributions.ExponentialDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":610
 * 			self._summarize( items_p, weights_p, n )
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython function to get the MLE estimate for a Gaussian."""
 * 
 */

static void __pyx_f_11pomegranate_13distributions_23ExponentialDistribution__summarize(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self, double *__pyx_v_items, double *__pyx_v_weights, __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n) {
  double __pyx_v_xw_sum;
  double __pyx_v_w;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_i;
  __Pyx_RefNannyDeclarations
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_1;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_summarize", 0);
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif

  /* "pomegranate/distributions.pyx":611
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 * 		"""Cython function to get the MLE estimate for a Gaussian."""             # <<<<<<<<<<<<<<
 * 
 * 		cdef double xw_sum = 0, w = 0
 */
  /*try:*/ {

    /* "pomegranate/distributions.pyx":613
 * 		"""Cython function to get the MLE estimate for a Gaussian."""
 * 
 * 		cdef double xw_sum = 0, w = 0             # <<<<<<<<<<<<<<
 * 		cdef SIZE_t i
 * 
 */
    __pyx_v_xw_sum = 0.0;
    __pyx_v_w = 0.0;

    /* "pomegranate/distributions.pyx":617
 * 
 * 		# Calculate the average, which is the MLE mu estimate
 * 		for i in range(n):             # <<<<<<<<<<<<<<
 * 			xw_sum += items[i] * weights[i]
 * 			w += weights[i]
 */
    __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;

      /* "pomegranate/distributions.pyx":618
 * 		# Calculate the average, which is the MLE mu estimate
 * 		for i in range(n):
 * 			xw_sum += items[i] * weights[i]             # <<<<<<<<<<<<<<
 * 			w += weights[i]
 * 
 */
      __pyx_v_xw_sum = (__pyx_v_xw_sum + ((__pyx_v_items[__pyx_v_i]) * (__pyx_v_weights[__pyx_v_i])));

      /* "pomegranate/distributions.pyx":619
 * 		for i in range(n):
 * 			xw_sum += items[i] * weights[i]
 * 			w += weights[i]             # <<<<<<<<<<<<<<
 * 
 * 		with gil:
 */
      __pyx_v_w = (__pyx_v_w + (__pyx_v_weights[__pyx_v_i]));
    }

    /* "pomegranate/distributions.pyx":621
 * 			w += weights[i]
 * 
 * 		with gil:             # <<<<<<<<<<<<<<
 * 			self.summaries[0] += w
 * 			self.summaries[1] += xw_sum
 */
    {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        /*try:*/ {

          /* "pomegranate/distributions.pyx":622
 * 
 * 		with gil:
 * 			self.summaries[0] += w             # <<<<<<<<<<<<<<
 * 			self.summaries[1] += xw_sum
 * 
 */
          if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          __Pyx_INCREF(__pyx_v_self->__pyx_base.summaries);
          __pyx_t_3 = __pyx_v_self->__pyx_base.summaries;
          __pyx_t_4 = 0;
          if (unlikely(__pyx_t_3 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_t_3, __pyx_t_4, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L9_error;};
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_6 = PyFloat_FromDouble(__pyx_v_w); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(__pyx_t_3 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          if (unlikely(__Pyx_SetItemInt(__pyx_t_3, __pyx_t_4, __pyx_t_7, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "pomegranate/distributions.pyx":623
 * 		with gil:
 * 			self.summaries[0] += w
 * 			self.summaries[1] += xw_sum             # <<<<<<<<<<<<<<
 * 
 * 	def from_summaries( self, inertia=0.0 ):
 */
          if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          __Pyx_INCREF(__pyx_v_self->__pyx_base.summaries);
          __pyx_t_3 = __pyx_v_self->__pyx_base.summaries;
          __pyx_t_4 = 1;
          if (unlikely(__pyx_t_3 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_t_3, __pyx_t_4, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L9_error;};
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_6 = PyFloat_FromDouble(__pyx_v_xw_sum); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(__pyx_t_3 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          if (unlikely(__Pyx_SetItemInt(__pyx_t_3, __pyx_t_4, __pyx_t_5, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        }

        /* "pomegranate/distributions.pyx":621
 * 			w += weights[i]
 * 
 * 		with gil:             # <<<<<<<<<<<<<<
 * 			self.summaries[0] += w
 * 			self.summaries[1] += xw_sum
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            goto __pyx_L10;
          }
          __pyx_L9_error: {
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            goto __pyx_L4_error;
          }
          __pyx_L10:;
        }
    }
  }

  /* "pomegranate/distributions.pyx":611
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 * 		"""Cython function to get the MLE estimate for a Gaussian."""             # <<<<<<<<<<<<<<
 * 
 * 		cdef double xw_sum = 0, w = 0
 */
  /*finally:*/ {
    /*normal exit:*/{
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L5;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "pomegranate/distributions.pyx":610
 * 			self._summarize( items_p, weights_p, n )
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython function to get the MLE estimate for a Gaussian."""
 * 
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("pomegranate.distributions.ExponentialDistribution._summarize", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 1);
  __pyx_L0:;
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
}

/* "pomegranate/distributions.pyx":625
 * 			self.summaries[1] += xw_sum
 * 
 * 	def from_summaries( self, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Takes in a series of summaries, represented as a mean, a variance, and
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_9from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_23ExponentialDistribution_8from_summaries[] = "\n\t\tTakes in a series of summaries, represented as a mean, a variance, and\n\t\ta weight, and updates the underlying distribution. Notes on how to do\n\t\tthis for a Gaussian distribution were taken from here:\n\t\thttp://math.stackexchange.com/questions/453113/how-to-merge-two-gaussians\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_9from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_summaries (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_inertia,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_summaries") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_inertia = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_summaries", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.ExponentialDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_8from_summaries(((struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *)__pyx_v_self), __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_23ExponentialDistribution_8from_summaries(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_inertia) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  double __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_summaries", 0);

  /* "pomegranate/distributions.pyx":633
 * 		"""
 * 
 * 		if self.frozen == True or self.summaries[0] == 0.0:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_2 = ((__pyx_v_self->__pyx_base.frozen == 1) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = __Pyx_PyFloat_EqObjC(PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 0), __pyx_float_0_0, 0.0, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":634
 * 
 * 		if self.frozen == True or self.summaries[0] == 0.0:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		self.rate = self.summaries[0] / self.summaries[1]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":633
 * 		"""
 * 
 * 		if self.frozen == True or self.summaries[0] == 0.0:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":636
 * 			return
 * 
 * 		self.rate = self.summaries[0] / self.summaries[1]             # <<<<<<<<<<<<<<
 * 		self.summaries = [0, 0]
 * 
 */
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = __Pyx_PyNumber_Divide(PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 0), PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_self->rate = __pyx_t_4;

  /* "pomegranate/distributions.pyx":637
 * 
 * 		self.rate = self.summaries[0] / self.summaries[1]
 * 		self.summaries = [0, 0]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.summaries);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.summaries);
  __pyx_v_self->__pyx_base.summaries = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":625
 * 			self.summaries[1] += xw_sum
 * 
 * 	def from_summaries( self, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Takes in a series of summaries, represented as a mean, a variance, and
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.ExponentialDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":647
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [ self.alpha, self.beta ]
 * 		def __set__( self, parameters ):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_16BetaDistribution_10parameters_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_16BetaDistribution_10parameters_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_16BetaDistribution_10parameters___get__(((struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_16BetaDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pomegranate/distributions.pyx":648
 * 	property parameters:
 * 		def __get__( self ):
 * 			return [ self.alpha, self.beta ]             # <<<<<<<<<<<<<<
 * 		def __set__( self, parameters ):
 * 			self.alpha, self.beta = parameters
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->alpha); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->beta); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":647
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [ self.alpha, self.beta ]
 * 		def __set__( self, parameters ):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.BetaDistribution.parameters.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":649
 * 		def __get__( self ):
 * 			return [ self.alpha, self.beta ]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.alpha, self.beta = parameters
 * 
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_16BetaDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_16BetaDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_16BetaDistribution_10parameters_2__set__(((struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_parameters));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_16BetaDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *(*__pyx_t_4)(PyObject *);
  double __pyx_t_5;
  double __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "pomegranate/distributions.pyx":650
 * 			return [ self.alpha, self.beta ]
 * 		def __set__( self, parameters ):
 * 			self.alpha, self.beta = parameters             # <<<<<<<<<<<<<<
 * 
 * 	def __init__( self, alpha, beta, frozen=False ):
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_parameters))) || (PyList_CheckExact(__pyx_v_parameters))) {
    PyObject* sequence = __pyx_v_parameters;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_v_parameters); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->alpha = __pyx_t_5;
  __pyx_v_self->beta = __pyx_t_6;

  /* "pomegranate/distributions.pyx":649
 * 		def __get__( self ):
 * 			return [ self.alpha, self.beta ]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.alpha, self.beta = parameters
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.BetaDistribution.parameters.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":652
 * 			self.alpha, self.beta = parameters
 * 
 * 	def __init__( self, alpha, beta, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Make a new beta distribution. Both alpha and beta are both shape
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_16BetaDistribution_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_16BetaDistribution___init__[] = "\n\t\tMake a new beta distribution. Both alpha and beta are both shape\n\t\tparameters.\n\t\t";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_11pomegranate_13distributions_16BetaDistribution___init__;
#endif
static int __pyx_pw_11pomegranate_13distributions_16BetaDistribution_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_alpha = 0;
  PyObject *__pyx_v_beta = 0;
  PyObject *__pyx_v_frozen = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_alpha,&__pyx_n_s_beta,&__pyx_n_s_frozen,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alpha)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_beta)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_alpha = values[0];
    __pyx_v_beta = values[1];
    __pyx_v_frozen = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.BetaDistribution.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_16BetaDistribution___init__(((struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *)__pyx_v_self), __pyx_v_alpha, __pyx_v_beta, __pyx_v_frozen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_16BetaDistribution___init__(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self, PyObject *__pyx_v_alpha, PyObject *__pyx_v_beta, PyObject *__pyx_v_frozen) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pomegranate/distributions.pyx":658
 * 		"""
 * 
 * 		self.alpha = alpha             # <<<<<<<<<<<<<<
 * 		self.beta = beta
 * 		self.summaries = []
 */
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_alpha); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->alpha = __pyx_t_1;

  /* "pomegranate/distributions.pyx":659
 * 
 * 		self.alpha = alpha
 * 		self.beta = beta             # <<<<<<<<<<<<<<
 * 		self.summaries = []
 * 		self.name = "BetaDistribution"
 */
  __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_beta); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->beta = __pyx_t_1;

  /* "pomegranate/distributions.pyx":660
 * 		self.alpha = alpha
 * 		self.beta = beta
 * 		self.summaries = []             # <<<<<<<<<<<<<<
 * 		self.name = "BetaDistribution"
 * 		self.frozen = frozen
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.summaries);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.summaries);
  __pyx_v_self->__pyx_base.summaries = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":661
 * 		self.beta = beta
 * 		self.summaries = []
 * 		self.name = "BetaDistribution"             # <<<<<<<<<<<<<<
 * 		self.frozen = frozen
 * 
 */
  __Pyx_INCREF(__pyx_n_s_BetaDistribution);
  __Pyx_GIVEREF(__pyx_n_s_BetaDistribution);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.name);
  __pyx_v_self->__pyx_base.name = __pyx_n_s_BetaDistribution;

  /* "pomegranate/distributions.pyx":662
 * 		self.summaries = []
 * 		self.name = "BetaDistribution"
 * 		self.frozen = frozen             # <<<<<<<<<<<<<<
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_frozen); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->__pyx_base.frozen = __pyx_t_3;

  /* "pomegranate/distributions.pyx":652
 * 			self.alpha, self.beta = parameters
 * 
 * 	def __init__( self, alpha, beta, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Make a new beta distribution. Both alpha and beta are both shape
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pomegranate.distributions.BetaDistribution.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":664
 * 		self.frozen = frozen
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

static double __pyx_f_11pomegranate_13distributions_16BetaDistribution__log_probability(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self, double __pyx_v_symbol) {
  double __pyx_v_a;
  double __pyx_v_b;
  double __pyx_r;
  double __pyx_t_1;

  /* "pomegranate/distributions.pyx":667
 * 		"""Cython optimized function for log probability calculation."""
 * 
 * 		cdef double a = self.alpha, b = self.beta             # <<<<<<<<<<<<<<
 * 
 * 		return ( _log(lgamma(a+b)) - _log(lgamma(a)) -
 */
  __pyx_t_1 = __pyx_v_self->alpha;
  __pyx_v_a = __pyx_t_1;
  __pyx_t_1 = __pyx_v_self->beta;
  __pyx_v_b = __pyx_t_1;

  /* "pomegranate/distributions.pyx":670
 * 
 * 		return ( _log(lgamma(a+b)) - _log(lgamma(a)) -
 * 			_log(lgamma(b)) + (a-1)*_log(symbol) +             # <<<<<<<<<<<<<<
 * 			(b-1)*_log(1.-symbol) )
 * 
 */
  __pyx_r = ((((__pyx_f_11pomegranate_5utils__log(lgamma((__pyx_v_a + __pyx_v_b))) - __pyx_f_11pomegranate_5utils__log(lgamma(__pyx_v_a))) - __pyx_f_11pomegranate_5utils__log(lgamma(__pyx_v_b))) + ((__pyx_v_a - 1.0) * __pyx_f_11pomegranate_5utils__log(__pyx_v_symbol))) + ((__pyx_v_b - 1.0) * __pyx_f_11pomegranate_5utils__log((1. - __pyx_v_symbol))));
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":664
 * 		self.frozen = frozen
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":673
 * 			(b-1)*_log(1.-symbol) )
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""Return a random sample from the beta distribution."""
 * 		return random.betavariate( self.alpha, self.beta )
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_16BetaDistribution_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_16BetaDistribution_2sample[] = "Return a random sample from the beta distribution.";
static PyObject *__pyx_pw_11pomegranate_13distributions_16BetaDistribution_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_16BetaDistribution_2sample(((struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_16BetaDistribution_2sample(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);

  /* "pomegranate/distributions.pyx":675
 * 	def sample( self ):
 * 		"""Return a random sample from the beta distribution."""
 * 		return random.betavariate( self.alpha, self.beta )             # <<<<<<<<<<<<<<
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0 ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_betavariate); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->alpha); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->beta); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_5) {
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":673
 * 			(b-1)*_log(1.-symbol) )
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""Return a random sample from the beta distribution."""
 * 		return random.betavariate( self.alpha, self.beta )
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.BetaDistribution.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":677
 * 		return random.betavariate( self.alpha, self.beta )
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_16BetaDistribution_5from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_16BetaDistribution_4from_sample[] = "\n\t\tSet the parameters of this Distribution to maximize the likelihood of \n\t\tthe given sample. Items holds some sort of sequence. If weights is \n\t\tspecified, it holds a sequence of value to weight each item by.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_16BetaDistribution_5from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,&__pyx_n_s_inertia,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_inertia = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_sample", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.BetaDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_16BetaDistribution_4from_sample(((struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights, __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_16BetaDistribution_4from_sample(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_sample", 0);

  /* "pomegranate/distributions.pyx":684
 * 		"""
 * 
 * 		if self.frozen:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_1 = (__pyx_v_self->__pyx_base.frozen != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":685
 * 
 * 		if self.frozen:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		self.summarize( items, weights )
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":684
 * 		"""
 * 
 * 		if self.frozen:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":687
 * 			return
 * 
 * 		self.summarize( items, weights )             # <<<<<<<<<<<<<<
 * 		self.from_summaries( inertia )
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_summarize); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_4) {
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  }
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_weights);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":688
 * 
 * 		self.summarize( items, weights )
 * 		self.from_summaries( inertia )             # <<<<<<<<<<<<<<
 * 
 * 	def summarize( self, items, weights=None ):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_summaries); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_inertia); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_INCREF(__pyx_v_inertia);
    __Pyx_GIVEREF(__pyx_v_inertia);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_inertia);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":677
 * 		return random.betavariate( self.alpha, self.beta )
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pomegranate.distributions.BetaDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":690
 * 		self.from_summaries( inertia )
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in a series of items and their weights and reduce it down to a
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_16BetaDistribution_7summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_16BetaDistribution_6summarize[] = "\n\t\tTake in a series of items and their weights and reduce it down to a\n\t\tsummary statistic to be used in training later.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_16BetaDistribution_7summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("summarize (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "summarize") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("summarize", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.BetaDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_16BetaDistribution_6summarize(((struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_16BetaDistribution_6summarize(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights) {
  double *__pyx_v_items_p;
  double *__pyx_v_weights_p;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("summarize", 0);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":696
 * 		"""
 * 
 * 		items, weights = weight_set( items, weights )             # <<<<<<<<<<<<<<
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_weight_set); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_3) {
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  }
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_weights);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_5 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __Pyx_DECREF_SET(__pyx_v_items, __pyx_t_2);
  __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":698
 * 		items, weights = weight_set( items, weights )
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data             # <<<<<<<<<<<<<<
 * 		cdef double* weights_p = <double*> (<numpy.ndarray> weights).data
 * 		cdef SIZE_t n = items.shape[0]
 */
  __pyx_v_items_p = ((double *)((PyArrayObject *)__pyx_v_items)->data);

  /* "pomegranate/distributions.pyx":699
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 * 		cdef double* weights_p = <double*> (<numpy.ndarray> weights).data             # <<<<<<<<<<<<<<
 * 		cdef SIZE_t n = items.shape[0]
 * 
 */
  __pyx_v_weights_p = ((double *)((PyArrayObject *)__pyx_v_weights)->data);

  /* "pomegranate/distributions.pyx":700
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 * 		cdef double* weights_p = <double*> (<numpy.ndarray> weights).data
 * 		cdef SIZE_t n = items.shape[0]             # <<<<<<<<<<<<<<
 * 
 * 		with nogil:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_items, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_Py_intptr_t(__pyx_t_5); if (unlikely((__pyx_t_7 == (npy_intp)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_n = __pyx_t_7;

  /* "pomegranate/distributions.pyx":702
 * 		cdef SIZE_t n = items.shape[0]
 * 
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			self._summarize( items_p, weights_p, n )
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "pomegranate/distributions.pyx":703
 * 
 * 		with nogil:
 * 			self._summarize( items_p, weights_p, n )             # <<<<<<<<<<<<<<
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 */
        ((struct __pyx_vtabstruct_11pomegranate_13distributions_BetaDistribution *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._summarize(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), __pyx_v_items_p, __pyx_v_weights_p, __pyx_v_n);
      }

      /* "pomegranate/distributions.pyx":702
 * 		cdef SIZE_t n = items.shape[0]
 * 
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			self._summarize( items_p, weights_p, n )
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L7;
        }
        __pyx_L7:;
      }
  }

  /* "pomegranate/distributions.pyx":690
 * 		self.from_summaries( inertia )
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in a series of items and their weights and reduce it down to a
 */

  /* function exit code */
  __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_5);
  __Pyx_AddTraceback("pomegranate.distributions.BetaDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":705
 * 			self._summarize( items_p, weights_p, n )
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for summarizing some data."""
 * 
 */

static void __pyx_f_11pomegranate_13distributions_16BetaDistribution__summarize(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self, double *__pyx_v_items, double *__pyx_v_weights, __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n) {
  double __pyx_v_successes;
  double __pyx_v_failures;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_i;
  __Pyx_RefNannyDeclarations
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_1;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_summarize", 0);
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif

  /* "pomegranate/distributions.pyx":706
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 * 		"""Cython optimized function for summarizing some data."""             # <<<<<<<<<<<<<<
 * 
 * 		cdef double successes = 0, failures = 0
 */
  /*try:*/ {

    /* "pomegranate/distributions.pyx":708
 * 		"""Cython optimized function for summarizing some data."""
 * 
 * 		cdef double successes = 0, failures = 0             # <<<<<<<<<<<<<<
 * 		cdef SIZE_t i
 * 
 */
    __pyx_v_successes = 0.0;
    __pyx_v_failures = 0.0;

    /* "pomegranate/distributions.pyx":711
 * 		cdef SIZE_t i
 * 
 * 		for i in range(n):             # <<<<<<<<<<<<<<
 * 			if items[i] == 1:
 * 				successes += weights[i]
 */
    __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;

      /* "pomegranate/distributions.pyx":712
 * 
 * 		for i in range(n):
 * 			if items[i] == 1:             # <<<<<<<<<<<<<<
 * 				successes += weights[i]
 * 			else:
 */
      __pyx_t_3 = (((__pyx_v_items[__pyx_v_i]) == 1.0) != 0);
      if (__pyx_t_3) {

        /* "pomegranate/distributions.pyx":713
 * 		for i in range(n):
 * 			if items[i] == 1:
 * 				successes += weights[i]             # <<<<<<<<<<<<<<
 * 			else:
 * 				failures += weights[i]
 */
        __pyx_v_successes = (__pyx_v_successes + (__pyx_v_weights[__pyx_v_i]));

        /* "pomegranate/distributions.pyx":712
 * 
 * 		for i in range(n):
 * 			if items[i] == 1:             # <<<<<<<<<<<<<<
 * 				successes += weights[i]
 * 			else:
 */
        goto __pyx_L8;
      }

      /* "pomegranate/distributions.pyx":715
 * 				successes += weights[i]
 * 			else:
 * 				failures += weights[i]             # <<<<<<<<<<<<<<
 * 
 * 		with gil:
 */
      /*else*/ {
        __pyx_v_failures = (__pyx_v_failures + (__pyx_v_weights[__pyx_v_i]));
      }
      __pyx_L8:;
    }

    /* "pomegranate/distributions.pyx":717
 * 				failures += weights[i]
 * 
 * 		with gil:             # <<<<<<<<<<<<<<
 * 			self.summaries.append( (successes, failures) )
 * 
 */
    {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        /*try:*/ {

          /* "pomegranate/distributions.pyx":718
 * 
 * 		with gil:
 * 			self.summaries.append( (successes, failures) )             # <<<<<<<<<<<<<<
 * 
 * 	def from_summaries( self, inertia=0.0 ):
 */
          if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
            PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
          }
          __pyx_t_4 = PyFloat_FromDouble(__pyx_v_successes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_5 = PyFloat_FromDouble(__pyx_v_failures); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
          __pyx_t_4 = 0;
          __pyx_t_5 = 0;
          __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_self->__pyx_base.summaries, __pyx_t_6); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }

        /* "pomegranate/distributions.pyx":717
 * 				failures += weights[i]
 * 
 * 		with gil:             # <<<<<<<<<<<<<<
 * 			self.summaries.append( (successes, failures) )
 * 
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            goto __pyx_L11;
          }
          __pyx_L10_error: {
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            goto __pyx_L4_error;
          }
          __pyx_L11:;
        }
    }
  }

  /* "pomegranate/distributions.pyx":706
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 * 		"""Cython optimized function for summarizing some data."""             # <<<<<<<<<<<<<<
 * 
 * 		cdef double successes = 0, failures = 0
 */
  /*finally:*/ {
    /*normal exit:*/{
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L5;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "pomegranate/distributions.pyx":705
 * 			self._summarize( items_p, weights_p, n )
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for summarizing some data."""
 * 
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("pomegranate.distributions.BetaDistribution._summarize", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 1);
  __pyx_L0:;
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
}

/* "pomegranate/distributions.pyx":720
 * 			self.summaries.append( (successes, failures) )
 * 
 * 	def from_summaries( self, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""Use the summaries in order to update the distribution."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_16BetaDistribution_9from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_16BetaDistribution_8from_summaries[] = "Use the summaries in order to update the distribution.";
static PyObject *__pyx_pw_11pomegranate_13distributions_16BetaDistribution_9from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_summaries (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_inertia,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_summaries") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_inertia = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_summaries", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.BetaDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_16BetaDistribution_8from_summaries(((struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *)__pyx_v_self), __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_16BetaDistribution_8from_summaries(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *__pyx_v_self, PyObject *__pyx_v_inertia) {
  CYTHON_UNUSED PyObject *__pyx_v_summaries = NULL;
  PyObject *__pyx_v_successes = NULL;
  PyObject *__pyx_v_failures = NULL;
  PyObject *__pyx_v_alpha = NULL;
  PyObject *__pyx_v_beta = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  double __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_summaries", 0);

  /* "pomegranate/distributions.pyx":723
 * 		"""Use the summaries in order to update the distribution."""
 * 
 * 		summaries = numpy.array( self.summaries )             # <<<<<<<<<<<<<<
 * 
 * 		successes, failures = 0, 0
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->__pyx_base.summaries); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_self->__pyx_base.summaries);
    __Pyx_GIVEREF(__pyx_v_self->__pyx_base.summaries);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->__pyx_base.summaries);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_summaries = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":725
 * 		summaries = numpy.array( self.summaries )
 * 
 * 		successes, failures = 0, 0             # <<<<<<<<<<<<<<
 * 		for alpha, beta in self.summaries:
 * 			successes += alpha
 */
  __pyx_t_1 = __pyx_int_0;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3 = __pyx_int_0;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_v_successes = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_failures = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":726
 * 
 * 		successes, failures = 0, 0
 * 		for alpha, beta in self.summaries:             # <<<<<<<<<<<<<<
 * 			successes += alpha
 * 			failures += beta
 */
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = __pyx_v_self->__pyx_base.summaries; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
  for (;;) {
    if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      #else
      __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
      index = 0; __pyx_t_4 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      index = 1; __pyx_t_2 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_7 = NULL;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_alpha, __pyx_t_4);
    __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_beta, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pomegranate/distributions.pyx":727
 * 		successes, failures = 0, 0
 * 		for alpha, beta in self.summaries:
 * 			successes += alpha             # <<<<<<<<<<<<<<
 * 			failures += beta
 * 
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_successes, __pyx_v_alpha); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_successes, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":728
 * 		for alpha, beta in self.summaries:
 * 			successes += alpha
 * 			failures += beta             # <<<<<<<<<<<<<<
 * 
 * 		self.alpha = self.alpha*inertia + successes*(1-inertia)
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_failures, __pyx_v_beta); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_failures, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":726
 * 
 * 		successes, failures = 0, 0
 * 		for alpha, beta in self.summaries:             # <<<<<<<<<<<<<<
 * 			successes += alpha
 * 			failures += beta
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":730
 * 			failures += beta
 * 
 * 		self.alpha = self.alpha*inertia + successes*(1-inertia)             # <<<<<<<<<<<<<<
 * 		self.beta = self.beta*inertia + failures*(1-inertia)
 * 
 */
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->alpha); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyNumber_Multiply(__pyx_t_3, __pyx_v_inertia); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_inertia, 1, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyNumber_Multiply(__pyx_v_successes, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_self->alpha = __pyx_t_8;

  /* "pomegranate/distributions.pyx":731
 * 
 * 		self.alpha = self.alpha*inertia + successes*(1-inertia)
 * 		self.beta = self.beta*inertia + failures*(1-inertia)             # <<<<<<<<<<<<<<
 * 
 * 		self.summaries = []
 */
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->beta); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyNumber_Multiply(__pyx_t_3, __pyx_v_inertia); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_inertia, 1, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyNumber_Multiply(__pyx_v_failures, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_self->beta = __pyx_t_8;

  /* "pomegranate/distributions.pyx":733
 * 		self.beta = self.beta*inertia + failures*(1-inertia)
 * 
 * 		self.summaries = []             # <<<<<<<<<<<<<<
 * 
 * cdef class GammaDistribution( Distribution ):
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.summaries);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.summaries);
  __pyx_v_self->__pyx_base.summaries = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":720
 * 			self.summaries.append( (successes, failures) )
 * 
 * 	def from_summaries( self, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""Use the summaries in order to update the distribution."""
 * 
 */

  /* function exit code */
  __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);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pomegranate.distributions.BetaDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_summaries);
  __Pyx_XDECREF(__pyx_v_successes);
  __Pyx_XDECREF(__pyx_v_failures);
  __Pyx_XDECREF(__pyx_v_alpha);
  __Pyx_XDECREF(__pyx_v_beta);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":745
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [ self.alpha, self.beta ]
 * 		def __set__( self, parameters ):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_17GammaDistribution_10parameters_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_17GammaDistribution_10parameters_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_17GammaDistribution_10parameters___get__(((struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_17GammaDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pomegranate/distributions.pyx":746
 * 	property parameters:
 * 		def __get__( self ):
 * 			return [ self.alpha, self.beta ]             # <<<<<<<<<<<<<<
 * 		def __set__( self, parameters ):
 * 			self.alpha, self.beta = parameters
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->alpha); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->beta); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":745
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [ self.alpha, self.beta ]
 * 		def __set__( self, parameters ):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.GammaDistribution.parameters.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":747
 * 		def __get__( self ):
 * 			return [ self.alpha, self.beta ]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.alpha, self.beta = parameters
 * 
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_17GammaDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_17GammaDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_17GammaDistribution_10parameters_2__set__(((struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_parameters));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_17GammaDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *(*__pyx_t_4)(PyObject *);
  double __pyx_t_5;
  double __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "pomegranate/distributions.pyx":748
 * 			return [ self.alpha, self.beta ]
 * 		def __set__( self, parameters ):
 * 			self.alpha, self.beta = parameters             # <<<<<<<<<<<<<<
 * 
 * 	def __cinit__( self, double alpha, double beta, bint frozen=False ):
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_parameters))) || (PyList_CheckExact(__pyx_v_parameters))) {
    PyObject* sequence = __pyx_v_parameters;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_v_parameters); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->alpha = __pyx_t_5;
  __pyx_v_self->beta = __pyx_t_6;

  /* "pomegranate/distributions.pyx":747
 * 		def __get__( self ):
 * 			return [ self.alpha, self.beta ]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.alpha, self.beta = parameters
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.GammaDistribution.parameters.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":750
 * 			self.alpha, self.beta = parameters
 * 
 * 	def __cinit__( self, double alpha, double beta, bint frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Make a new gamma distribution. Alpha is the shape parameter and beta is
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_17GammaDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_17GammaDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_alpha;
  double __pyx_v_beta;
  int __pyx_v_frozen;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_alpha,&__pyx_n_s_beta,&__pyx_n_s_frozen,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alpha)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_beta)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_alpha = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_alpha == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_beta = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_beta == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[2]) {
      __pyx_v_frozen = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_frozen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_frozen = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.GammaDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_17GammaDistribution___cinit__(((struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *)__pyx_v_self), __pyx_v_alpha, __pyx_v_beta, __pyx_v_frozen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_17GammaDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *__pyx_v_self, double __pyx_v_alpha, double __pyx_v_beta, int __pyx_v_frozen) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "pomegranate/distributions.pyx":756
 * 		"""
 * 
 * 		self.alpha = alpha             # <<<<<<<<<<<<<<
 * 		self.beta = beta
 * 		self.summaries = []
 */
  __pyx_v_self->alpha = __pyx_v_alpha;

  /* "pomegranate/distributions.pyx":757
 * 
 * 		self.alpha = alpha
 * 		self.beta = beta             # <<<<<<<<<<<<<<
 * 		self.summaries = []
 * 		self.name = "GammaDistribution"
 */
  __pyx_v_self->beta = __pyx_v_beta;

  /* "pomegranate/distributions.pyx":758
 * 		self.alpha = alpha
 * 		self.beta = beta
 * 		self.summaries = []             # <<<<<<<<<<<<<<
 * 		self.name = "GammaDistribution"
 * 		self.frozen = frozen
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.summaries);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.summaries);
  __pyx_v_self->__pyx_base.summaries = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":759
 * 		self.beta = beta
 * 		self.summaries = []
 * 		self.name = "GammaDistribution"             # <<<<<<<<<<<<<<
 * 		self.frozen = frozen
 * 
 */
  __Pyx_INCREF(__pyx_n_s_GammaDistribution);
  __Pyx_GIVEREF(__pyx_n_s_GammaDistribution);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.name);
  __pyx_v_self->__pyx_base.name = __pyx_n_s_GammaDistribution;

  /* "pomegranate/distributions.pyx":760
 * 		self.summaries = []
 * 		self.name = "GammaDistribution"
 * 		self.frozen = frozen             # <<<<<<<<<<<<<<
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:
 */
  __pyx_v_self->__pyx_base.frozen = __pyx_v_frozen;

  /* "pomegranate/distributions.pyx":750
 * 			self.alpha, self.beta = parameters
 * 
 * 	def __cinit__( self, double alpha, double beta, bint frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Make a new gamma distribution. Alpha is the shape parameter and beta is
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.GammaDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":762
 * 		self.frozen = frozen
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

static double __pyx_f_11pomegranate_13distributions_17GammaDistribution__log_probability(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *__pyx_v_self, double __pyx_v_symbol) {
  double __pyx_v_alpha;
  double __pyx_v_beta;
  double __pyx_r;
  double __pyx_t_1;

  /* "pomegranate/distributions.pyx":765
 * 		"""Cython optimized function for log probability calculation."""
 * 
 * 		cdef double alpha = self.alpha, beta = self.beta             # <<<<<<<<<<<<<<
 * 
 * 		return (_log(beta) * alpha - lgamma(alpha) + _log(symbol)
 */
  __pyx_t_1 = __pyx_v_self->alpha;
  __pyx_v_alpha = __pyx_t_1;
  __pyx_t_1 = __pyx_v_self->beta;
  __pyx_v_beta = __pyx_t_1;

  /* "pomegranate/distributions.pyx":768
 * 
 * 		return (_log(beta) * alpha - lgamma(alpha) + _log(symbol)
 * 			* (alpha - 1) - beta * symbol)             # <<<<<<<<<<<<<<
 * 
 * 	def sample( self ):
 */
  __pyx_r = ((((__pyx_f_11pomegranate_5utils__log(__pyx_v_beta) * __pyx_v_alpha) - lgamma(__pyx_v_alpha)) + (__pyx_f_11pomegranate_5utils__log(__pyx_v_symbol) * (__pyx_v_alpha - 1.0))) - (__pyx_v_beta * __pyx_v_symbol));
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":762
 * 		self.frozen = frozen
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":770
 * 			* (alpha - 1) - beta * symbol)
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Sample from this gamma distribution and return the value sampled.
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_17GammaDistribution_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_17GammaDistribution_2sample[] = "\n\t\tSample from this gamma distribution and return the value sampled.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_17GammaDistribution_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_17GammaDistribution_2sample(((struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_17GammaDistribution_2sample(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);

  /* "pomegranate/distributions.pyx":779
 * 		# alpha, beta parameterization, our alpha/beta are shape/rate, while its
 * 		# alpha/beta are shape/scale. So we have to mess with the parameters.
 * 		return random.gammavariate(self.parameters[0], 1.0 / self.parameters[1])             # <<<<<<<<<<<<<<
 * 
 * 	def from_sample( self, items, weights=None, inertia=0.0, epsilon=1E-9,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_gammavariate); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyFloat_DivideCObj(__pyx_float_1_0, __pyx_t_5, 1.0, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_5) {
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":770
 * 			* (alpha - 1) - beta * symbol)
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Sample from this gamma distribution and return the value sampled.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.GammaDistribution.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":781
 * 		return random.gammavariate(self.parameters[0], 1.0 / self.parameters[1])
 * 
 * 	def from_sample( self, items, weights=None, inertia=0.0, epsilon=1E-9,             # <<<<<<<<<<<<<<
 * 		iteration_limit=1000 ):
 * 		"""
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_17GammaDistribution_5from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_17GammaDistribution_4from_sample[] = "\n\t\tSet the parameters of this Distribution to maximize the likelihood of \n\t\tthe given sample. Items holds some sort of sequence. If weights is \n\t\tspecified, it holds a sequence of value to weight each item by.\n\t\t\n\t\tIn the Gamma case, likelihood maximization is necesarily numerical, and \n\t\tthe extension to weighted values is not trivially obvious. The algorithm\n\t\tused here includes a Newton-Raphson step for shape parameter estimation,\n\t\tand analytical calculation of the rate parameter. The extension to \n\t\tweights is constructed using vital information found way down at the \n\t\tbottom of an Experts Exchange page.\n\t\t\n\t\tNewton-Raphson continues until the change in the parameter is less than \n\t\tepsilon, or until iteration_limit is reached\n\t\t\n\t\tSee:\n\t\thttp://en.wikipedia.org/wiki/Gamma_distribution\n\t\thttp://www.experts-exchange.com/Other/Math_Science/Q_23943764.html\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_17GammaDistribution_5from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  PyObject *__pyx_v_inertia = 0;
  PyObject *__pyx_v_epsilon = 0;
  PyObject *__pyx_v_iteration_limit = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,&__pyx_n_s_inertia,&__pyx_n_s_epsilon,&__pyx_n_s_iteration_limit,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_float_0_0);
    values[3] = ((PyObject *)__pyx_float_1Eneg_9);
    values[4] = ((PyObject *)__pyx_int_1000);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_epsilon);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_iteration_limit);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_inertia = values[2];
    __pyx_v_epsilon = values[3];
    __pyx_v_iteration_limit = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_sample", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.GammaDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_17GammaDistribution_4from_sample(((struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights, __pyx_v_inertia, __pyx_v_epsilon, __pyx_v_iteration_limit);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_17GammaDistribution_4from_sample(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia, PyObject *__pyx_v_epsilon, PyObject *__pyx_v_iteration_limit) {
  PyObject *__pyx_v_statistic = NULL;
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_new_shape = NULL;
  PyObject *__pyx_v_iteration = NULL;
  PyObject *__pyx_v_rate = NULL;
  PyObject *__pyx_v_prior_shape = NULL;
  PyObject *__pyx_v_prior_rate = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  double __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_sample", 0);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":804
 * 
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if len(items) == 0 or self.frozen == True:             # <<<<<<<<<<<<<<
 * 			# No sample, so just ignore it and keep our old parameters.
 * 			return
 */
  __pyx_t_2 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = ((__pyx_t_2 == 0) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = ((__pyx_v_self->__pyx_base.frozen == 1) != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":806
 * 		if len(items) == 0 or self.frozen == True:
 * 			# No sample, so just ignore it and keep our old parameters.
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		# Make it be a numpy array
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":804
 * 
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if len(items) == 0 or self.frozen == True:             # <<<<<<<<<<<<<<
 * 			# No sample, so just ignore it and keep our old parameters.
 * 			return
 */
  }

  /* "pomegranate/distributions.pyx":809
 * 
 * 		# Make it be a numpy array
 * 		items = numpy.asarray(items)             # <<<<<<<<<<<<<<
 * 
 * 		if weights is None:
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_asarray); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_items); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_INCREF(__pyx_v_items);
    __Pyx_GIVEREF(__pyx_v_items);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_items);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v_items, __pyx_t_4);
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":811
 * 		items = numpy.asarray(items)
 * 
 * 		if weights is None:             # <<<<<<<<<<<<<<
 * 			# Weight everything 1 if no weights specified
 * 			weights = numpy.ones_like(items)
 */
  __pyx_t_1 = (__pyx_v_weights == Py_None);
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (__pyx_t_3) {

    /* "pomegranate/distributions.pyx":813
 * 		if weights is None:
 * 			# Weight everything 1 if no weights specified
 * 			weights = numpy.ones_like(items)             # <<<<<<<<<<<<<<
 * 		else:
 * 			# Force whatever we have to be a Numpy array
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_ones_like); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_items); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_items);
      __Pyx_GIVEREF(__pyx_v_items);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_items);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":811
 * 		items = numpy.asarray(items)
 * 
 * 		if weights is None:             # <<<<<<<<<<<<<<
 * 			# Weight everything 1 if no weights specified
 * 			weights = numpy.ones_like(items)
 */
    goto __pyx_L6;
  }

  /* "pomegranate/distributions.pyx":816
 * 		else:
 * 			# Force whatever we have to be a Numpy array
 * 			weights = numpy.asarray(weights)             # <<<<<<<<<<<<<<
 * 
 * 		if weights.sum() == 0:
 */
  /*else*/ {
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_asarray); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_weights); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_INCREF(__pyx_v_weights);
      __Pyx_GIVEREF(__pyx_v_weights);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_weights);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_4);
    __pyx_t_4 = 0;
  }
  __pyx_L6:;

  /* "pomegranate/distributions.pyx":818
 * 			weights = numpy.asarray(weights)
 * 
 * 		if weights.sum() == 0:             # <<<<<<<<<<<<<<
 * 			# Since negative weights are banned, we must have no data.
 * 			# Don't change the parameters at all.
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_weights, __pyx_n_s_sum); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_6) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyInt_EqObjC(__pyx_t_4, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_3) {

    /* "pomegranate/distributions.pyx":821
 * 			# Since negative weights are banned, we must have no data.
 * 			# Don't change the parameters at all.
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		# First, do Newton-Raphson for shape parameter.
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":818
 * 			weights = numpy.asarray(weights)
 * 
 * 		if weights.sum() == 0:             # <<<<<<<<<<<<<<
 * 			# Since negative weights are banned, we must have no data.
 * 			# Don't change the parameters at all.
 */
  }

  /* "pomegranate/distributions.pyx":829
 * 		# outside the log function. (In retrospect, this is actually pretty
 * 		# obvious.)
 * 		statistic = (log(numpy.average(items, weights=weights)) -             # <<<<<<<<<<<<<<
 * 			numpy.average(log(items), weights=weights))
 * 
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_average); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_items);
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_weights, __pyx_v_weights) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL;
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":830
 * 		# obvious.)
 * 		statistic = (log(numpy.average(items, weights=weights)) -
 * 			numpy.average(log(items), weights=weights))             # <<<<<<<<<<<<<<
 * 
 * 		# Start our Newton-Raphson at what Wikipedia claims a 1969 paper claims
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_average); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_items); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
    __Pyx_INCREF(__pyx_v_items);
    __Pyx_GIVEREF(__pyx_v_items);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_items);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_weights, __pyx_v_weights) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, __pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":829
 * 		# outside the log function. (In retrospect, this is actually pretty
 * 		# obvious.)
 * 		statistic = (log(numpy.average(items, weights=weights)) -             # <<<<<<<<<<<<<<
 * 			numpy.average(log(items), weights=weights))
 * 
 */
  __pyx_t_4 = PyNumber_Subtract(__pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_statistic = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":835
 * 		# is a good approximation.
 * 		# Really, start with new_shape set, and shape set to be far away from it
 * 		shape = float("inf")             # <<<<<<<<<<<<<<
 * 
 * 		if statistic != 0:
 */
  __pyx_t_10 = __Pyx_PyObject_AsDouble(__pyx_n_s_inf); if (unlikely(__pyx_t_10 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyFloat_FromDouble(__pyx_t_10); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_shape = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":837
 * 		shape = float("inf")
 * 
 * 		if statistic != 0:             # <<<<<<<<<<<<<<
 * 			# Not going to have a divide by 0 problem here, so use the good
 * 			# estimate
 */
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_statistic, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_3) {

    /* "pomegranate/distributions.pyx":840
 * 			# Not going to have a divide by 0 problem here, so use the good
 * 			# estimate
 * 			new_shape =  (3 - statistic + csqrt((statistic - 3) ** 2 + 24 *             # <<<<<<<<<<<<<<
 * 				statistic)) / (12 * statistic)
 * 		if statistic == 0 or new_shape <= 0:
 */
    __pyx_t_4 = __Pyx_PyInt_SubtractCObj(__pyx_int_3, __pyx_v_statistic, 3, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyInt_SubtractObjC(__pyx_v_statistic, __pyx_int_3, 3, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = PyNumber_Power(__pyx_t_7, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "pomegranate/distributions.pyx":841
 * 			# estimate
 * 			new_shape =  (3 - statistic + csqrt((statistic - 3) ** 2 + 24 *
 * 				statistic)) / (12 * statistic)             # <<<<<<<<<<<<<<
 * 		if statistic == 0 or new_shape <= 0:
 * 			# Try the current shape parameter
 */
    __pyx_t_7 = PyNumber_Multiply(__pyx_int_24, __pyx_v_statistic); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);

    /* "pomegranate/distributions.pyx":840
 * 			# Not going to have a divide by 0 problem here, so use the good
 * 			# estimate
 * 			new_shape =  (3 - statistic + csqrt((statistic - 3) ** 2 + 24 *             # <<<<<<<<<<<<<<
 * 				statistic)) / (12 * statistic)
 * 		if statistic == 0 or new_shape <= 0:
 */
    __pyx_t_9 = PyNumber_Add(__pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyFloat_FromDouble(sqrt(__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_7 = PyNumber_Add(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "pomegranate/distributions.pyx":841
 * 			# estimate
 * 			new_shape =  (3 - statistic + csqrt((statistic - 3) ** 2 + 24 *
 * 				statistic)) / (12 * statistic)             # <<<<<<<<<<<<<<
 * 		if statistic == 0 or new_shape <= 0:
 * 			# Try the current shape parameter
 */
    __pyx_t_9 = PyNumber_Multiply(__pyx_int_12, __pyx_v_statistic); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_t_9); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_v_new_shape = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":837
 * 		shape = float("inf")
 * 
 * 		if statistic != 0:             # <<<<<<<<<<<<<<
 * 			# Not going to have a divide by 0 problem here, so use the good
 * 			# estimate
 */
  }

  /* "pomegranate/distributions.pyx":842
 * 			new_shape =  (3 - statistic + csqrt((statistic - 3) ** 2 + 24 *
 * 				statistic)) / (12 * statistic)
 * 		if statistic == 0 or new_shape <= 0:             # <<<<<<<<<<<<<<
 * 			# Try the current shape parameter
 * 			new_shape = self.parameters[0]
 */
  __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_v_statistic, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!__pyx_t_1) {
  } else {
    __pyx_t_3 = __pyx_t_1;
    goto __pyx_L10_bool_binop_done;
  }
  if (unlikely(!__pyx_v_new_shape)) { __Pyx_RaiseUnboundLocalError("new_shape"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_new_shape, __pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_3 = __pyx_t_1;
  __pyx_L10_bool_binop_done:;
  if (__pyx_t_3) {

    /* "pomegranate/distributions.pyx":844
 * 		if statistic == 0 or new_shape <= 0:
 * 			# Try the current shape parameter
 * 			new_shape = self.parameters[0]             # <<<<<<<<<<<<<<
 * 
 * 		# Count the iterations we take
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_new_shape, __pyx_t_9);
    __pyx_t_9 = 0;

    /* "pomegranate/distributions.pyx":842
 * 			new_shape =  (3 - statistic + csqrt((statistic - 3) ** 2 + 24 *
 * 				statistic)) / (12 * statistic)
 * 		if statistic == 0 or new_shape <= 0:             # <<<<<<<<<<<<<<
 * 			# Try the current shape parameter
 * 			new_shape = self.parameters[0]
 */
  }

  /* "pomegranate/distributions.pyx":847
 * 
 * 		# Count the iterations we take
 * 		iteration = 0             # <<<<<<<<<<<<<<
 * 
 * 		# Now do the update loop.
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_iteration = __pyx_int_0;

  /* "pomegranate/distributions.pyx":854
 * 		# is the digamma function (0th derivative of the digamma), and
 * 		# scipy.special.polygamma(1, x) is the trigamma function.
 * 		while abs(shape - new_shape) > epsilon and iteration < iteration_limit:             # <<<<<<<<<<<<<<
 * 			shape = new_shape
 * 
 */
  while (1) {
    if (unlikely(!__pyx_v_new_shape)) { __Pyx_RaiseUnboundLocalError("new_shape"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_9 = PyNumber_Subtract(__pyx_v_shape, __pyx_v_new_shape); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_4 = PyNumber_Absolute(__pyx_t_9); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyObject_RichCompare(__pyx_t_4, __pyx_v_epsilon, Py_GT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (__pyx_t_1) {
    } else {
      __pyx_t_3 = __pyx_t_1;
      goto __pyx_L14_bool_binop_done;
    }
    __pyx_t_9 = PyObject_RichCompare(__pyx_v_iteration, __pyx_v_iteration_limit, Py_LT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_3 = __pyx_t_1;
    __pyx_L14_bool_binop_done:;
    if (!__pyx_t_3) break;

    /* "pomegranate/distributions.pyx":855
 * 		# scipy.special.polygamma(1, x) is the trigamma function.
 * 		while abs(shape - new_shape) > epsilon and iteration < iteration_limit:
 * 			shape = new_shape             # <<<<<<<<<<<<<<
 * 
 * 			new_shape = shape - (log(shape) -
 */
    if (unlikely(!__pyx_v_new_shape)) { __Pyx_RaiseUnboundLocalError("new_shape"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __Pyx_INCREF(__pyx_v_new_shape);
    __Pyx_DECREF_SET(__pyx_v_shape, __pyx_v_new_shape);

    /* "pomegranate/distributions.pyx":857
 * 			shape = new_shape
 * 
 * 			new_shape = shape - (log(shape) -             # <<<<<<<<<<<<<<
 * 				scipy.special.polygamma(0, shape) -
 * 				statistic) / (1.0 / shape - scipy.special.polygamma(1, shape))
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_shape); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_INCREF(__pyx_v_shape);
      __Pyx_GIVEREF(__pyx_v_shape);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_shape);
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":858
 * 
 * 			new_shape = shape - (log(shape) -
 * 				scipy.special.polygamma(0, shape) -             # <<<<<<<<<<<<<<
 * 				statistic) / (1.0 / shape - scipy.special.polygamma(1, shape))
 * 
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_scipy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_special); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_polygamma); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    __pyx_t_2 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_2 = 1;
      }
    }
    __pyx_t_6 = PyTuple_New(2+__pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_2, __pyx_int_0);
    __Pyx_INCREF(__pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_2, __pyx_v_shape);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "pomegranate/distributions.pyx":857
 * 			shape = new_shape
 * 
 * 			new_shape = shape - (log(shape) -             # <<<<<<<<<<<<<<
 * 				scipy.special.polygamma(0, shape) -
 * 				statistic) / (1.0 / shape - scipy.special.polygamma(1, shape))
 */
    __pyx_t_5 = PyNumber_Subtract(__pyx_t_9, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":858
 * 
 * 			new_shape = shape - (log(shape) -
 * 				scipy.special.polygamma(0, shape) -             # <<<<<<<<<<<<<<
 * 				statistic) / (1.0 / shape - scipy.special.polygamma(1, shape))
 * 
 */
    __pyx_t_4 = PyNumber_Subtract(__pyx_t_5, __pyx_v_statistic); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "pomegranate/distributions.pyx":859
 * 			new_shape = shape - (log(shape) -
 * 				scipy.special.polygamma(0, shape) -
 * 				statistic) / (1.0 / shape - scipy.special.polygamma(1, shape))             # <<<<<<<<<<<<<<
 * 
 * 			# Don't let shape escape from valid values
 */
    __pyx_t_5 = __Pyx_PyFloat_DivideCObj(__pyx_float_1_0, __pyx_v_shape, 1.0, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_scipy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_special); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_polygamma); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    __pyx_t_2 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_2 = 1;
      }
    }
    __pyx_t_8 = PyTuple_New(2+__pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_INCREF(__pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_2, __pyx_int_1);
    __Pyx_INCREF(__pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_2, __pyx_v_shape);
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_Subtract(__pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "pomegranate/distributions.pyx":857
 * 			shape = new_shape
 * 
 * 			new_shape = shape - (log(shape) -             # <<<<<<<<<<<<<<
 * 				scipy.special.polygamma(0, shape) -
 * 				statistic) / (1.0 / shape - scipy.special.polygamma(1, shape))
 */
    __pyx_t_6 = PyNumber_Subtract(__pyx_v_shape, __pyx_t_9); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF_SET(__pyx_v_new_shape, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "pomegranate/distributions.pyx":862
 * 
 * 			# Don't let shape escape from valid values
 * 			if abs(new_shape) == float("inf") or new_shape == 0:             # <<<<<<<<<<<<<<
 * 				# Hack the shape parameter so we don't stop the loop if we land
 * 				# near it.
 */
    __pyx_t_6 = PyNumber_Absolute(__pyx_v_new_shape); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_10 = __Pyx_PyObject_AsDouble(__pyx_n_s_inf); if (unlikely(__pyx_t_10 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = PyFloat_FromDouble(__pyx_t_10); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_6, __pyx_t_9, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!__pyx_t_1) {
    } else {
      __pyx_t_3 = __pyx_t_1;
      goto __pyx_L17_bool_binop_done;
    }
    __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_v_new_shape, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_3 = __pyx_t_1;
    __pyx_L17_bool_binop_done:;
    if (__pyx_t_3) {

      /* "pomegranate/distributions.pyx":865
 * 				# Hack the shape parameter so we don't stop the loop if we land
 * 				# near it.
 * 				shape = new_shape             # <<<<<<<<<<<<<<
 * 
 * 				# Re-start at some random place.
 */
      __Pyx_INCREF(__pyx_v_new_shape);
      __Pyx_DECREF_SET(__pyx_v_shape, __pyx_v_new_shape);

      /* "pomegranate/distributions.pyx":868
 * 
 * 				# Re-start at some random place.
 * 				new_shape = random.random()             # <<<<<<<<<<<<<<
 * 
 * 			iteration += 1
 */
      __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_random); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (__pyx_t_9) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_9); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF_SET(__pyx_v_new_shape, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "pomegranate/distributions.pyx":862
 * 
 * 			# Don't let shape escape from valid values
 * 			if abs(new_shape) == float("inf") or new_shape == 0:             # <<<<<<<<<<<<<<
 * 				# Hack the shape parameter so we don't stop the loop if we land
 * 				# near it.
 */
    }

    /* "pomegranate/distributions.pyx":870
 * 				new_shape = random.random()
 * 
 * 			iteration += 1             # <<<<<<<<<<<<<<
 * 
 * 		# Might as well grab the new value
 */
    __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_v_iteration, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_iteration, __pyx_t_4);
    __pyx_t_4 = 0;
  }

  /* "pomegranate/distributions.pyx":873
 * 
 * 		# Might as well grab the new value
 * 		shape = new_shape             # <<<<<<<<<<<<<<
 * 
 * 		# Now our iterative estimation of the shape parameter has converged.
 */
  if (unlikely(!__pyx_v_new_shape)) { __Pyx_RaiseUnboundLocalError("new_shape"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __Pyx_INCREF(__pyx_v_new_shape);
  __Pyx_DECREF_SET(__pyx_v_shape, __pyx_v_new_shape);

  /* "pomegranate/distributions.pyx":877
 * 		# Now our iterative estimation of the shape parameter has converged.
 * 		# Calculate the rate parameter
 * 		rate = 1.0 / (1.0 / (shape * weights.sum()) * items.dot(weights) )             # <<<<<<<<<<<<<<
 * 
 * 		# Get the previous parameters
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_weights, __pyx_n_s_sum); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (__pyx_t_9) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_9); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Multiply(__pyx_v_shape, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyFloat_DivideCObj(__pyx_float_1_0, __pyx_t_6, 1.0, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_items, __pyx_n_s_dot); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_weights); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_INCREF(__pyx_v_weights);
    __Pyx_GIVEREF(__pyx_v_weights);
    PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_weights);
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyNumber_Multiply(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyFloat_DivideCObj(__pyx_float_1_0, __pyx_t_9, 1.0, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_rate = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "pomegranate/distributions.pyx":880
 * 
 * 		# Get the previous parameters
 * 		prior_shape, prior_rate = self.parameters             # <<<<<<<<<<<<<<
 * 
 * 		# Calculate the new parameters, respecting inertia, with an inertia
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
    PyObject* sequence = __pyx_t_6;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_9 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_8 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_11 = Py_TYPE(__pyx_t_8)->tp_iternext;
    index = 0; __pyx_t_9 = __pyx_t_11(__pyx_t_8); if (unlikely(!__pyx_t_9)) goto __pyx_L19_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_9);
    index = 1; __pyx_t_4 = __pyx_t_11(__pyx_t_8); if (unlikely(!__pyx_t_4)) goto __pyx_L19_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = NULL;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    goto __pyx_L20_unpacking_done;
    __pyx_L19_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_11 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L20_unpacking_done:;
  }
  __pyx_v_prior_shape = __pyx_t_9;
  __pyx_t_9 = 0;
  __pyx_v_prior_rate = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":885
 * 		# of 0 being completely replacing the parameters, and an inertia of
 * 		# 1 being to ignore new training data.
 * 		self.alpha = prior_shape*inertia + shape*(1-inertia)             # <<<<<<<<<<<<<<
 * 		self.beta = prior_rate*inertia + rate*(1-inertia)
 * 
 */
  __pyx_t_6 = PyNumber_Multiply(__pyx_v_prior_shape, __pyx_v_inertia); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_inertia, 1, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = PyNumber_Multiply(__pyx_v_shape, __pyx_t_4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Add(__pyx_t_6, __pyx_t_9); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_self->alpha = __pyx_t_10;

  /* "pomegranate/distributions.pyx":886
 * 		# 1 being to ignore new training data.
 * 		self.alpha = prior_shape*inertia + shape*(1-inertia)
 * 		self.beta = prior_rate*inertia + rate*(1-inertia)             # <<<<<<<<<<<<<<
 * 
 * 	def summarize( self, items, weights=None ):
 */
  __pyx_t_4 = PyNumber_Multiply(__pyx_v_prior_rate, __pyx_v_inertia); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_inertia, 1, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_6 = PyNumber_Multiply(__pyx_v_rate, __pyx_t_9); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyNumber_Add(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_self->beta = __pyx_t_10;

  /* "pomegranate/distributions.pyx":781
 * 		return random.gammavariate(self.parameters[0], 1.0 / self.parameters[1])
 * 
 * 	def from_sample( self, items, weights=None, inertia=0.0, epsilon=1E-9,             # <<<<<<<<<<<<<<
 * 		iteration_limit=1000 ):
 * 		"""
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pomegranate.distributions.GammaDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_statistic);
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_new_shape);
  __Pyx_XDECREF(__pyx_v_iteration);
  __Pyx_XDECREF(__pyx_v_rate);
  __Pyx_XDECREF(__pyx_v_prior_shape);
  __Pyx_XDECREF(__pyx_v_prior_rate);
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":888
 * 		self.beta = prior_rate*inertia + rate*(1-inertia)
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in a series of items and their weights and reduce it down to a
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_17GammaDistribution_7summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_17GammaDistribution_6summarize[] = "\n\t\tTake in a series of items and their weights and reduce it down to a\n\t\tsummary statistic to be used in training later.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_17GammaDistribution_7summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("summarize (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "summarize") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("summarize", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.GammaDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_17GammaDistribution_6summarize(((struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_17GammaDistribution_6summarize(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("summarize", 0);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":894
 * 		"""
 * 
 * 		if len(items) == 0:             # <<<<<<<<<<<<<<
 * 			# No sample, so just ignore it and keep our old parameters.
 * 			return
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((__pyx_t_1 == 0) != 0);
  if (__pyx_t_2) {

    /* "pomegranate/distributions.pyx":896
 * 		if len(items) == 0:
 * 			# No sample, so just ignore it and keep our old parameters.
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		# Make it be a numpy array
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":894
 * 		"""
 * 
 * 		if len(items) == 0:             # <<<<<<<<<<<<<<
 * 			# No sample, so just ignore it and keep our old parameters.
 * 			return
 */
  }

  /* "pomegranate/distributions.pyx":899
 * 
 * 		# Make it be a numpy array
 * 		items = numpy.asarray(items)             # <<<<<<<<<<<<<<
 * 
 * 		if weights is None:
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_asarray); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_items); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_INCREF(__pyx_v_items);
    __Pyx_GIVEREF(__pyx_v_items);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_items);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF_SET(__pyx_v_items, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":901
 * 		items = numpy.asarray(items)
 * 
 * 		if weights is None:             # <<<<<<<<<<<<<<
 * 			# Weight everything 1 if no weights specified
 * 			weights = numpy.ones_like(items)
 */
  __pyx_t_2 = (__pyx_v_weights == Py_None);
  __pyx_t_7 = (__pyx_t_2 != 0);
  if (__pyx_t_7) {

    /* "pomegranate/distributions.pyx":903
 * 		if weights is None:
 * 			# Weight everything 1 if no weights specified
 * 			weights = numpy.ones_like(items)             # <<<<<<<<<<<<<<
 * 		else:
 * 			# Force whatever we have to be a Numpy array
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ones_like); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_items); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_INCREF(__pyx_v_items);
      __Pyx_GIVEREF(__pyx_v_items);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_items);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":901
 * 		items = numpy.asarray(items)
 * 
 * 		if weights is None:             # <<<<<<<<<<<<<<
 * 			# Weight everything 1 if no weights specified
 * 			weights = numpy.ones_like(items)
 */
    goto __pyx_L4;
  }

  /* "pomegranate/distributions.pyx":906
 * 		else:
 * 			# Force whatever we have to be a Numpy array
 * 			weights = numpy.asarray(weights)             # <<<<<<<<<<<<<<
 * 
 * 		if weights.sum() == 0:
 */
  /*else*/ {
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_weights); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_weights);
      __Pyx_GIVEREF(__pyx_v_weights);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_weights);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L4:;

  /* "pomegranate/distributions.pyx":908
 * 			weights = numpy.asarray(weights)
 * 
 * 		if weights.sum() == 0:             # <<<<<<<<<<<<<<
 * 			# Since negative weights are banned, we must have no data.
 * 			# Don't change the parameters at all.
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_weights, __pyx_n_s_sum); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_7) {

    /* "pomegranate/distributions.pyx":911
 * 			# Since negative weights are banned, we must have no data.
 * 			# Don't change the parameters at all.
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		# Save the weighted average of the items, and the weighted average of
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":908
 * 			weights = numpy.asarray(weights)
 * 
 * 		if weights.sum() == 0:             # <<<<<<<<<<<<<<
 * 			# Since negative weights are banned, we must have no data.
 * 			# Don't change the parameters at all.
 */
  }

  /* "pomegranate/distributions.pyx":915
 * 		# Save the weighted average of the items, and the weighted average of
 * 		# the log of the items.
 * 		self.summaries.append( [ numpy.average( items, weights=weights ),             # <<<<<<<<<<<<<<
 * 								 numpy.average( log(items), weights=weights ),
 * 								 items.dot( weights ),
 */
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_average); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_items);
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_weights, __pyx_v_weights) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":916
 * 		# the log of the items.
 * 		self.summaries.append( [ numpy.average( items, weights=weights ),
 * 								 numpy.average( log(items), weights=weights ),             # <<<<<<<<<<<<<<
 * 								 items.dot( weights ),
 * 								 weights.sum() ] )
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_average); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_items); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
    __Pyx_INCREF(__pyx_v_items);
    __Pyx_GIVEREF(__pyx_v_items);
    PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_items);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_weights, __pyx_v_weights) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":917
 * 		self.summaries.append( [ numpy.average( items, weights=weights ),
 * 								 numpy.average( log(items), weights=weights ),
 * 								 items.dot( weights ),             # <<<<<<<<<<<<<<
 * 								 weights.sum() ] )
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_items, __pyx_n_s_dot); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_weights); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_INCREF(__pyx_v_weights);
    __Pyx_GIVEREF(__pyx_v_weights);
    PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_weights);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":918
 * 								 numpy.average( log(items), weights=weights ),
 * 								 items.dot( weights ),
 * 								 weights.sum() ] )             # <<<<<<<<<<<<<<
 * 
 * 	def from_summaries( self, inertia=0.0, epsilon=1E-9,
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_weights, __pyx_n_s_sum); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "pomegranate/distributions.pyx":915
 * 		# Save the weighted average of the items, and the weighted average of
 * 		# the log of the items.
 * 		self.summaries.append( [ numpy.average( items, weights=weights ),             # <<<<<<<<<<<<<<
 * 								 numpy.average( log(items), weights=weights ),
 * 								 items.dot( weights ),
 */
  __pyx_t_8 = PyList_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_6);
  PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_9);
  PyList_SET_ITEM(__pyx_t_8, 1, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_5);
  PyList_SET_ITEM(__pyx_t_8, 2, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  PyList_SET_ITEM(__pyx_t_8, 3, __pyx_t_3);
  __pyx_t_6 = 0;
  __pyx_t_9 = 0;
  __pyx_t_5 = 0;
  __pyx_t_3 = 0;
  __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_self->__pyx_base.summaries, __pyx_t_8); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "pomegranate/distributions.pyx":888
 * 		self.beta = prior_rate*inertia + rate*(1-inertia)
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in a series of items and their weights and reduce it down to a
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pomegranate.distributions.GammaDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":920
 * 								 weights.sum() ] )
 * 
 * 	def from_summaries( self, inertia=0.0, epsilon=1E-9,             # <<<<<<<<<<<<<<
 * 		iteration_limit=1000 ):
 * 		"""
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_17GammaDistribution_9from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_17GammaDistribution_8from_summaries[] = "\n\t\tSet the parameters of this Distribution to maximize the likelihood of \n\t\tthe given sample given the summaries which have been stored.\n\t\t\n\t\tIn the Gamma case, likelihood maximization is necesarily numerical, and \n\t\tthe extension to weighted values is not trivially obvious. The algorithm\n\t\tused here includes a Newton-Raphson step for shape parameter estimation,\n\t\tand analytical calculation of the rate parameter. The extension to \n\t\tweights is constructed using vital information found way down at the \n\t\tbottom of an Experts Exchange page.\n\t\t\n\t\tNewton-Raphson continues until the change in the parameter is less than \n\t\tepsilon, or until iteration_limit is reached\n\n\t\tSee:\n\t\thttp://en.wikipedia.org/wiki/Gamma_distribution\n\t\thttp://www.experts-exchange.com/Other/Math_Science/Q_23943764.html\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_17GammaDistribution_9from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_inertia = 0;
  PyObject *__pyx_v_epsilon = 0;
  PyObject *__pyx_v_iteration_limit = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_summaries (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_inertia,&__pyx_n_s_epsilon,&__pyx_n_s_iteration_limit,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)__pyx_float_0_0);
    values[1] = ((PyObject *)__pyx_float_1Eneg_9);
    values[2] = ((PyObject *)__pyx_int_1000);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_epsilon);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_iteration_limit);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_summaries") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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;
      }
    }
    __pyx_v_inertia = values[0];
    __pyx_v_epsilon = values[1];
    __pyx_v_iteration_limit = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_summaries", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.GammaDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_17GammaDistribution_8from_summaries(((struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *)__pyx_v_self), __pyx_v_inertia, __pyx_v_epsilon, __pyx_v_iteration_limit);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_17GammaDistribution_8from_summaries(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *__pyx_v_self, PyObject *__pyx_v_inertia, PyObject *__pyx_v_epsilon, PyObject *__pyx_v_iteration_limit) {
  PyObject *__pyx_v_summaries = NULL;
  PyObject *__pyx_v_statistic = NULL;
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_new_shape = NULL;
  PyObject *__pyx_v_iteration = NULL;
  PyObject *__pyx_v_rate = NULL;
  PyObject *__pyx_v_prior_shape = NULL;
  PyObject *__pyx_v_prior_rate = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  double __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *(*__pyx_t_11)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_summaries", 0);

  /* "pomegranate/distributions.pyx":942
 * 
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if len(self.summaries) == 0 or self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_2 = __pyx_v_self->__pyx_base.summaries;
  __Pyx_INCREF(__pyx_t_2);
  if (unlikely(__pyx_t_2 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = PyList_GET_SIZE(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = ((__pyx_t_3 == 0) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_self->__pyx_base.frozen == 1) != 0);
  __pyx_t_1 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":943
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if len(self.summaries) == 0 or self.frozen == True:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		# First, do Newton-Raphson for shape parameter.
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":942
 * 
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if len(self.summaries) == 0 or self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":951
 * 		# outside the log function. (In retrospect, this is actually pretty
 * 		# obvious.)
 * 		summaries = numpy.array( self.summaries )             # <<<<<<<<<<<<<<
 * 
 * 		statistic = _log( numpy.average( summaries[:,0],
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_array); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_self->__pyx_base.summaries); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_INCREF(__pyx_v_self->__pyx_base.summaries);
    __Pyx_GIVEREF(__pyx_v_self->__pyx_base.summaries);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_self->__pyx_base.summaries);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_summaries = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":953
 * 		summaries = numpy.array( self.summaries )
 * 
 * 		statistic = _log( numpy.average( summaries[:,0],             # <<<<<<<<<<<<<<
 * 											 weights=summaries[:,3] ) ) - \
 * 					numpy.average( summaries[:,1],
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_average); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetItem(__pyx_v_summaries, __pyx_tuple__8); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":954
 * 
 * 		statistic = _log( numpy.average( summaries[:,0],
 * 											 weights=summaries[:,3] ) ) - \             # <<<<<<<<<<<<<<
 * 					numpy.average( summaries[:,1],
 * 								   weights=summaries[:,3] )
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = PyObject_GetItem(__pyx_v_summaries, __pyx_tuple__10); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_weights, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":953
 * 		summaries = numpy.array( self.summaries )
 * 
 * 		statistic = _log( numpy.average( summaries[:,0],             # <<<<<<<<<<<<<<
 * 											 weights=summaries[:,3] ) ) - \
 * 					numpy.average( summaries[:,1],
 */
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyFloat_FromDouble(__pyx_f_11pomegranate_5utils__log(__pyx_t_8)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "pomegranate/distributions.pyx":955
 * 		statistic = _log( numpy.average( summaries[:,0],
 * 											 weights=summaries[:,3] ) ) - \
 * 					numpy.average( summaries[:,1],             # <<<<<<<<<<<<<<
 * 								   weights=summaries[:,3] )
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_average); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetItem(__pyx_v_summaries, __pyx_tuple__12); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":956
 * 											 weights=summaries[:,3] ) ) - \
 * 					numpy.average( summaries[:,1],
 * 								   weights=summaries[:,3] )             # <<<<<<<<<<<<<<
 * 
 * 		# Start our Newton-Raphson at what Wikipedia claims a 1969 paper claims
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_9 = PyObject_GetItem(__pyx_v_summaries, __pyx_tuple__14); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_weights, __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "pomegranate/distributions.pyx":955
 * 		statistic = _log( numpy.average( summaries[:,0],
 * 											 weights=summaries[:,3] ) ) - \
 * 					numpy.average( summaries[:,1],             # <<<<<<<<<<<<<<
 * 								   weights=summaries[:,3] )
 * 
 */
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":954
 * 
 * 		statistic = _log( numpy.average( summaries[:,0],
 * 											 weights=summaries[:,3] ) ) - \             # <<<<<<<<<<<<<<
 * 					numpy.average( summaries[:,1],
 * 								   weights=summaries[:,3] )
 */
  __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_statistic = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":961
 * 		# is a good approximation.
 * 		# Really, start with new_shape set, and shape set to be far away from it
 * 		shape = float("inf")             # <<<<<<<<<<<<<<
 * 
 * 		if statistic != 0:
 */
  __pyx_t_8 = __Pyx_PyObject_AsDouble(__pyx_n_s_inf); if (unlikely(__pyx_t_8 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyFloat_FromDouble(__pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_shape = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":963
 * 		shape = float("inf")
 * 
 * 		if statistic != 0:             # <<<<<<<<<<<<<<
 * 			# Not going to have a divide by 0 problem here, so use the good
 * 			# estimate
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_statistic, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":966
 * 			# Not going to have a divide by 0 problem here, so use the good
 * 			# estimate
 * 			new_shape =  (3 - statistic + csqrt((statistic - 3) ** 2 + 24 *             # <<<<<<<<<<<<<<
 * 				statistic)) / (12 * statistic)
 * 		if statistic == 0 or new_shape <= 0:
 */
    __pyx_t_2 = __Pyx_PyInt_SubtractCObj(__pyx_int_3, __pyx_v_statistic, 3, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyInt_SubtractObjC(__pyx_v_statistic, __pyx_int_3, 3, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_5 = PyNumber_Power(__pyx_t_9, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "pomegranate/distributions.pyx":967
 * 			# estimate
 * 			new_shape =  (3 - statistic + csqrt((statistic - 3) ** 2 + 24 *
 * 				statistic)) / (12 * statistic)             # <<<<<<<<<<<<<<
 * 		if statistic == 0 or new_shape <= 0:
 * 			# Try the current shape parameter
 */
    __pyx_t_9 = PyNumber_Multiply(__pyx_int_24, __pyx_v_statistic); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);

    /* "pomegranate/distributions.pyx":966
 * 			# Not going to have a divide by 0 problem here, so use the good
 * 			# estimate
 * 			new_shape =  (3 - statistic + csqrt((statistic - 3) ** 2 + 24 *             # <<<<<<<<<<<<<<
 * 				statistic)) / (12 * statistic)
 * 		if statistic == 0 or new_shape <= 0:
 */
    __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyFloat_FromDouble(sqrt(__pyx_t_8)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = PyNumber_Add(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "pomegranate/distributions.pyx":967
 * 			# estimate
 * 			new_shape =  (3 - statistic + csqrt((statistic - 3) ** 2 + 24 *
 * 				statistic)) / (12 * statistic)             # <<<<<<<<<<<<<<
 * 		if statistic == 0 or new_shape <= 0:
 * 			# Try the current shape parameter
 */
    __pyx_t_6 = PyNumber_Multiply(__pyx_int_12, __pyx_v_statistic); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_t_9, __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_new_shape = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "pomegranate/distributions.pyx":963
 * 		shape = float("inf")
 * 
 * 		if statistic != 0:             # <<<<<<<<<<<<<<
 * 			# Not going to have a divide by 0 problem here, so use the good
 * 			# estimate
 */
  }

  /* "pomegranate/distributions.pyx":968
 * 			new_shape =  (3 - statistic + csqrt((statistic - 3) ** 2 + 24 *
 * 				statistic)) / (12 * statistic)
 * 		if statistic == 0 or new_shape <= 0:             # <<<<<<<<<<<<<<
 * 			# Try the current shape parameter
 * 			new_shape = self.parameters[0]
 */
  __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_v_statistic, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L8_bool_binop_done;
  }
  if (unlikely(!__pyx_v_new_shape)) { __Pyx_RaiseUnboundLocalError("new_shape"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_new_shape, __pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_1 = __pyx_t_4;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":970
 * 		if statistic == 0 or new_shape <= 0:
 * 			# Try the current shape parameter
 * 			new_shape = self.parameters[0]             # <<<<<<<<<<<<<<
 * 
 * 		# Count the iterations we take
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_new_shape, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "pomegranate/distributions.pyx":968
 * 			new_shape =  (3 - statistic + csqrt((statistic - 3) ** 2 + 24 *
 * 				statistic)) / (12 * statistic)
 * 		if statistic == 0 or new_shape <= 0:             # <<<<<<<<<<<<<<
 * 			# Try the current shape parameter
 * 			new_shape = self.parameters[0]
 */
  }

  /* "pomegranate/distributions.pyx":973
 * 
 * 		# Count the iterations we take
 * 		iteration = 0             # <<<<<<<<<<<<<<
 * 
 * 		# Now do the update loop.
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_iteration = __pyx_int_0;

  /* "pomegranate/distributions.pyx":980
 * 		# is the digamma function (0th derivative of the digamma), and
 * 		# scipy.special.polygamma(1, x) is the trigamma function.
 * 		while abs(shape - new_shape) > epsilon and iteration < iteration_limit:             # <<<<<<<<<<<<<<
 * 			shape = new_shape
 * 
 */
  while (1) {
    if (unlikely(!__pyx_v_new_shape)) { __Pyx_RaiseUnboundLocalError("new_shape"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_6 = PyNumber_Subtract(__pyx_v_shape, __pyx_v_new_shape); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyNumber_Absolute(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, __pyx_v_epsilon, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_4) {
    } else {
      __pyx_t_1 = __pyx_t_4;
      goto __pyx_L12_bool_binop_done;
    }
    __pyx_t_6 = PyObject_RichCompare(__pyx_v_iteration, __pyx_v_iteration_limit, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_1 = __pyx_t_4;
    __pyx_L12_bool_binop_done:;
    if (!__pyx_t_1) break;

    /* "pomegranate/distributions.pyx":981
 * 		# scipy.special.polygamma(1, x) is the trigamma function.
 * 		while abs(shape - new_shape) > epsilon and iteration < iteration_limit:
 * 			shape = new_shape             # <<<<<<<<<<<<<<
 * 
 * 			new_shape = shape - (_log(shape) -
 */
    if (unlikely(!__pyx_v_new_shape)) { __Pyx_RaiseUnboundLocalError("new_shape"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __Pyx_INCREF(__pyx_v_new_shape);
    __Pyx_DECREF_SET(__pyx_v_shape, __pyx_v_new_shape);

    /* "pomegranate/distributions.pyx":983
 * 			shape = new_shape
 * 
 * 			new_shape = shape - (_log(shape) -             # <<<<<<<<<<<<<<
 * 				scipy.special.polygamma(0, shape) -
 * 				statistic) / (1.0 / shape - scipy.special.polygamma(1, shape))
 */
    __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_v_shape); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = PyFloat_FromDouble(__pyx_f_11pomegranate_5utils__log(__pyx_t_8)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);

    /* "pomegranate/distributions.pyx":984
 * 
 * 			new_shape = shape - (_log(shape) -
 * 				scipy.special.polygamma(0, shape) -             # <<<<<<<<<<<<<<
 * 				statistic) / (1.0 / shape - scipy.special.polygamma(1, shape))
 * 
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_scipy); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_special); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_polygamma); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    __pyx_t_3 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
        __pyx_t_3 = 1;
      }
    }
    __pyx_t_7 = PyTuple_New(2+__pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_3, __pyx_int_0);
    __Pyx_INCREF(__pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_3, __pyx_v_shape);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "pomegranate/distributions.pyx":983
 * 			shape = new_shape
 * 
 * 			new_shape = shape - (_log(shape) -             # <<<<<<<<<<<<<<
 * 				scipy.special.polygamma(0, shape) -
 * 				statistic) / (1.0 / shape - scipy.special.polygamma(1, shape))
 */
    __pyx_t_9 = PyNumber_Subtract(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pomegranate/distributions.pyx":984
 * 
 * 			new_shape = shape - (_log(shape) -
 * 				scipy.special.polygamma(0, shape) -             # <<<<<<<<<<<<<<
 * 				statistic) / (1.0 / shape - scipy.special.polygamma(1, shape))
 * 
 */
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_9, __pyx_v_statistic); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "pomegranate/distributions.pyx":985
 * 			new_shape = shape - (_log(shape) -
 * 				scipy.special.polygamma(0, shape) -
 * 				statistic) / (1.0 / shape - scipy.special.polygamma(1, shape))             # <<<<<<<<<<<<<<
 * 
 * 			# Don't let shape escape from valid values
 */
    __pyx_t_9 = __Pyx_PyFloat_DivideCObj(__pyx_float_1_0, __pyx_v_shape, 1.0, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_scipy); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_special); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_polygamma); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    __pyx_t_3 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
        __pyx_t_3 = 1;
      }
    }
    __pyx_t_10 = PyTuple_New(2+__pyx_t_3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(__pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_3, __pyx_int_1);
    __Pyx_INCREF(__pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_3, __pyx_v_shape);
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyNumber_Subtract(__pyx_t_9, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyNumber_Divide(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "pomegranate/distributions.pyx":983
 * 			shape = new_shape
 * 
 * 			new_shape = shape - (_log(shape) -             # <<<<<<<<<<<<<<
 * 				scipy.special.polygamma(0, shape) -
 * 				statistic) / (1.0 / shape - scipy.special.polygamma(1, shape))
 */
    __pyx_t_7 = PyNumber_Subtract(__pyx_v_shape, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_new_shape, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "pomegranate/distributions.pyx":988
 * 
 * 			# Don't let shape escape from valid values
 * 			if abs(new_shape) == float("inf") or new_shape == 0:             # <<<<<<<<<<<<<<
 * 				# Hack the shape parameter so we don't stop the loop if we land
 * 				# near it.
 */
    __pyx_t_7 = PyNumber_Absolute(__pyx_v_new_shape); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_AsDouble(__pyx_n_s_inf); if (unlikely(__pyx_t_8 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = PyFloat_FromDouble(__pyx_t_8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_7, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!__pyx_t_4) {
    } else {
      __pyx_t_1 = __pyx_t_4;
      goto __pyx_L15_bool_binop_done;
    }
    __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_v_new_shape, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_1 = __pyx_t_4;
    __pyx_L15_bool_binop_done:;
    if (__pyx_t_1) {

      /* "pomegranate/distributions.pyx":991
 * 				# Hack the shape parameter so we don't stop the loop if we land
 * 				# near it.
 * 				shape = new_shape             # <<<<<<<<<<<<<<
 * 
 * 				# Re-start at some random place.
 */
      __Pyx_INCREF(__pyx_v_new_shape);
      __Pyx_DECREF_SET(__pyx_v_shape, __pyx_v_new_shape);

      /* "pomegranate/distributions.pyx":994
 * 
 * 				# Re-start at some random place.
 * 				new_shape = random.random()             # <<<<<<<<<<<<<<
 * 
 * 			iteration += 1
 */
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_random); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      if (__pyx_t_6) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF_SET(__pyx_v_new_shape, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "pomegranate/distributions.pyx":988
 * 
 * 			# Don't let shape escape from valid values
 * 			if abs(new_shape) == float("inf") or new_shape == 0:             # <<<<<<<<<<<<<<
 * 				# Hack the shape parameter so we don't stop the loop if we land
 * 				# near it.
 */
    }

    /* "pomegranate/distributions.pyx":996
 * 				new_shape = random.random()
 * 
 * 			iteration += 1             # <<<<<<<<<<<<<<
 * 
 * 		# Might as well grab the new value
 */
    __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_iteration, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_iteration, __pyx_t_2);
    __pyx_t_2 = 0;
  }

  /* "pomegranate/distributions.pyx":999
 * 
 * 		# Might as well grab the new value
 * 		shape = new_shape             # <<<<<<<<<<<<<<
 * 
 * 		# Now our iterative estimation of the shape parameter has converged.
 */
  if (unlikely(!__pyx_v_new_shape)) { __Pyx_RaiseUnboundLocalError("new_shape"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __Pyx_INCREF(__pyx_v_new_shape);
  __Pyx_DECREF_SET(__pyx_v_shape, __pyx_v_new_shape);

  /* "pomegranate/distributions.pyx":1003
 * 		# Now our iterative estimation of the shape parameter has converged.
 * 		# Calculate the rate parameter
 * 		rate = 1.0 / (1.0 / (shape * summaries[:,3].sum()) * \             # <<<<<<<<<<<<<<
 * 			numpy.sum( summaries[:,2] ) )
 * 
 */
  __pyx_t_7 = PyObject_GetItem(__pyx_v_summaries, __pyx_tuple__16); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_sum); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (__pyx_t_7) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Multiply(__pyx_v_shape, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyFloat_DivideCObj(__pyx_float_1_0, __pyx_t_6, 1.0, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "pomegranate/distributions.pyx":1004
 * 		# Calculate the rate parameter
 * 		rate = 1.0 / (1.0 / (shape * summaries[:,3].sum()) * \
 * 			numpy.sum( summaries[:,2] ) )             # <<<<<<<<<<<<<<
 * 
 * 		# Get the previous parameters
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_sum); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyObject_GetItem(__pyx_v_summaries, __pyx_tuple__18); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_10 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  if (!__pyx_t_10) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_10); __pyx_t_10 = NULL;
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "pomegranate/distributions.pyx":1003
 * 		# Now our iterative estimation of the shape parameter has converged.
 * 		# Calculate the rate parameter
 * 		rate = 1.0 / (1.0 / (shape * summaries[:,3].sum()) * \             # <<<<<<<<<<<<<<
 * 			numpy.sum( summaries[:,2] ) )
 * 
 */
  __pyx_t_9 = PyNumber_Multiply(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyFloat_DivideCObj(__pyx_float_1_0, __pyx_t_9, 1.0, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_rate = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "pomegranate/distributions.pyx":1007
 * 
 * 		# Get the previous parameters
 * 		prior_shape, prior_rate = self.parameters             # <<<<<<<<<<<<<<
 * 
 * 		# Calculate the new parameters, respecting inertia, with an inertia
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
    PyObject* sequence = __pyx_t_6;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_9 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_5 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_11 = Py_TYPE(__pyx_t_5)->tp_iternext;
    index = 0; __pyx_t_9 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_9)) goto __pyx_L17_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_9);
    index = 1; __pyx_t_2 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L17_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L18_unpacking_done;
    __pyx_L17_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_11 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L18_unpacking_done:;
  }
  __pyx_v_prior_shape = __pyx_t_9;
  __pyx_t_9 = 0;
  __pyx_v_prior_rate = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":1012
 * 		# of 0 being completely replacing the parameters, and an inertia of
 * 		# 1 being to ignore new training data.
 * 		self.alpha = prior_shape*inertia + shape*(1-inertia)             # <<<<<<<<<<<<<<
 * 		self.beta =	prior_rate*inertia + rate*(1-inertia)
 * 		self.summaries = []
 */
  __pyx_t_6 = PyNumber_Multiply(__pyx_v_prior_shape, __pyx_v_inertia); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_inertia, 1, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_9 = PyNumber_Multiply(__pyx_v_shape, __pyx_t_2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(__pyx_t_6, __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->alpha = __pyx_t_8;

  /* "pomegranate/distributions.pyx":1013
 * 		# 1 being to ignore new training data.
 * 		self.alpha = prior_shape*inertia + shape*(1-inertia)
 * 		self.beta =	prior_rate*inertia + rate*(1-inertia)             # <<<<<<<<<<<<<<
 * 		self.summaries = []
 * 
 */
  __pyx_t_2 = PyNumber_Multiply(__pyx_v_prior_rate, __pyx_v_inertia); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_9 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_inertia, 1, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_6 = PyNumber_Multiply(__pyx_v_rate, __pyx_t_9); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyNumber_Add(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_self->beta = __pyx_t_8;

  /* "pomegranate/distributions.pyx":1014
 * 		self.alpha = prior_shape*inertia + shape*(1-inertia)
 * 		self.beta =	prior_rate*inertia + rate*(1-inertia)
 * 		self.summaries = []             # <<<<<<<<<<<<<<
 * 
 * cdef class DiscreteDistribution( Distribution ):
 */
  __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.summaries);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.summaries);
  __pyx_v_self->__pyx_base.summaries = ((PyObject*)__pyx_t_9);
  __pyx_t_9 = 0;

  /* "pomegranate/distributions.pyx":920
 * 								 weights.sum() ] )
 * 
 * 	def from_summaries( self, inertia=0.0, epsilon=1E-9,             # <<<<<<<<<<<<<<
 * 		iteration_limit=1000 ):
 * 		"""
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("pomegranate.distributions.GammaDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_summaries);
  __Pyx_XDECREF(__pyx_v_statistic);
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_new_shape);
  __Pyx_XDECREF(__pyx_v_iteration);
  __Pyx_XDECREF(__pyx_v_rate);
  __Pyx_XDECREF(__pyx_v_prior_shape);
  __Pyx_XDECREF(__pyx_v_prior_rate);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1023
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [ self.dist ]
 * 		def __set__( self, parameters ):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_10parameters_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_10parameters_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_10parameters___get__(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pomegranate/distributions.pyx":1024
 * 	property parameters:
 * 		def __get__( self ):
 * 			return [ self.dist ]             # <<<<<<<<<<<<<<
 * 		def __set__( self, parameters ):
 * 			self.dist = parameters[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->dist);
  __Pyx_GIVEREF(__pyx_v_self->dist);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->dist);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1023
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [ self.dist ]
 * 		def __set__( self, parameters ):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.parameters.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1025
 * 		def __get__( self ):
 * 			return [ self.dist ]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.dist = parameters[0]
 * 
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_10parameters_2__set__(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_parameters));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "pomegranate/distributions.pyx":1026
 * 			return [ self.dist ]
 * 		def __set__( self, parameters ):
 * 			self.dist = parameters[0]             # <<<<<<<<<<<<<<
 * 
 * 	def __cinit__( self, dict characters, bint frozen=False ):
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_parameters, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->dist);
  __Pyx_DECREF(__pyx_v_self->dist);
  __pyx_v_self->dist = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1025
 * 		def __get__( self ):
 * 			return [ self.dist ]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.dist = parameters[0]
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.parameters.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1028
 * 			self.dist = parameters[0]
 * 
 * 	def __cinit__( self, dict characters, bint frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Make a new discrete distribution with a dictionary of discrete
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_characters = 0;
  int __pyx_v_frozen;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_characters,&__pyx_n_s_frozen,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_characters)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_characters = ((PyObject*)values[0]);
    if (values[1]) {
      __pyx_v_frozen = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_frozen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_frozen = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_characters), (&PyDict_Type), 1, "characters", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution___cinit__(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self), __pyx_v_characters, __pyx_v_frozen);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_characters, int __pyx_v_frozen) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  double __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "pomegranate/distributions.pyx":1036
 * 		"""
 * 
 * 		self.name = "DiscreteDistribution"             # <<<<<<<<<<<<<<
 * 		self.frozen = frozen
 * 
 */
  __Pyx_INCREF(__pyx_n_s_DiscreteDistribution);
  __Pyx_GIVEREF(__pyx_n_s_DiscreteDistribution);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.name);
  __pyx_v_self->__pyx_base.name = __pyx_n_s_DiscreteDistribution;

  /* "pomegranate/distributions.pyx":1037
 * 
 * 		self.name = "DiscreteDistribution"
 * 		self.frozen = frozen             # <<<<<<<<<<<<<<
 * 
 * 		self.dist = characters.copy()
 */
  __pyx_v_self->__pyx_base.frozen = __pyx_v_frozen;

  /* "pomegranate/distributions.pyx":1039
 * 		self.frozen = frozen
 * 
 * 		self.dist = characters.copy()             # <<<<<<<<<<<<<<
 * 		self.log_dist = { key: _log(value) for key, value in characters.items() }
 * 		self.summaries =[ { key: 0 for key in characters.keys() } ]
 */
  if (unlikely(__pyx_v_characters == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "copy");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyDict_Copy(__pyx_v_characters); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->dist);
  __Pyx_DECREF(__pyx_v_self->dist);
  __pyx_v_self->dist = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1040
 * 
 * 		self.dist = characters.copy()
 * 		self.log_dist = { key: _log(value) for key, value in characters.items() }             # <<<<<<<<<<<<<<
 * 		self.summaries =[ { key: 0 for key in characters.keys() } ]
 * 
 */
  { /* enter inner scope */
    PyObject *__pyx_7genexpr__pyx_v_key = NULL;
    PyObject *__pyx_7genexpr__pyx_v_value = NULL;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(__pyx_v_characters == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "items");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
    }
    __pyx_t_2 = __Pyx_PyDict_Items(__pyx_v_characters); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_5)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_5(__pyx_t_3);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        #else
        __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_7);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L9_unpacking_done;
        __pyx_L8_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __pyx_L9_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_key, __pyx_t_6);
      __pyx_t_6 = 0;
      __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_value, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_7genexpr__pyx_v_value); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __pyx_t_2 = PyFloat_FromDouble(__pyx_f_11pomegranate_5utils__log(__pyx_t_10)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (unlikely(PyDict_SetItem(__pyx_t_1, (PyObject*)__pyx_7genexpr__pyx_v_key, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_key);
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_value);
    goto __pyx_L10_exit_scope;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_key);
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_value);
    goto __pyx_L1_error;
    __pyx_L10_exit_scope:;
  } /* exit inner scope */
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->log_dist);
  __Pyx_DECREF(__pyx_v_self->log_dist);
  __pyx_v_self->log_dist = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1041
 * 		self.dist = characters.copy()
 * 		self.log_dist = { key: _log(value) for key, value in characters.items() }
 * 		self.summaries =[ { key: 0 for key in characters.keys() } ]             # <<<<<<<<<<<<<<
 * 
 * 		self.encoded_summary = 0
 */
  { /* enter inner scope */
    PyObject *__pyx_8genexpr1__pyx_v_key = NULL;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(__pyx_v_characters == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "keys");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
    }
    __pyx_t_3 = __Pyx_PyDict_Keys(__pyx_v_characters); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (likely(!__pyx_t_5)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_5(__pyx_t_2);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_key, __pyx_t_3);
      __pyx_t_3 = 0;
      if (unlikely(PyDict_SetItem(__pyx_t_1, (PyObject*)__pyx_8genexpr1__pyx_v_key, (PyObject*)__pyx_int_0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_key);
    goto __pyx_L16_exit_scope;
    __pyx_L13_error:;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_key);
    goto __pyx_L1_error;
    __pyx_L16_exit_scope:;
  } /* exit inner scope */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.summaries);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.summaries);
  __pyx_v_self->__pyx_base.summaries = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":1043
 * 		self.summaries =[ { key: 0 for key in characters.keys() } ]
 * 
 * 		self.encoded_summary = 0             # <<<<<<<<<<<<<<
 * 		self.encoded_keys = None
 * 		self.encoded_counts = NULL
 */
  __pyx_v_self->encoded_summary = 0;

  /* "pomegranate/distributions.pyx":1044
 * 
 * 		self.encoded_summary = 0
 * 		self.encoded_keys = None             # <<<<<<<<<<<<<<
 * 		self.encoded_counts = NULL
 * 		self.encoded_log_probability = NULL
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->encoded_keys);
  __Pyx_DECREF(__pyx_v_self->encoded_keys);
  __pyx_v_self->encoded_keys = ((PyObject*)Py_None);

  /* "pomegranate/distributions.pyx":1045
 * 		self.encoded_summary = 0
 * 		self.encoded_keys = None
 * 		self.encoded_counts = NULL             # <<<<<<<<<<<<<<
 * 		self.encoded_log_probability = NULL
 * 
 */
  __pyx_v_self->encoded_counts = NULL;

  /* "pomegranate/distributions.pyx":1046
 * 		self.encoded_keys = None
 * 		self.encoded_counts = NULL
 * 		self.encoded_log_probability = NULL             # <<<<<<<<<<<<<<
 * 
 * 	def __dealloc__( self ):
 */
  __pyx_v_self->encoded_log_probability = NULL;

  /* "pomegranate/distributions.pyx":1028
 * 			self.dist = parameters[0]
 * 
 * 	def __cinit__( self, dict characters, bint frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Make a new discrete distribution with a dictionary of discrete
 */

  /* function exit code */
  __pyx_r = 0;
  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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1048
 * 		self.encoded_log_probability = NULL
 * 
 * 	def __dealloc__( self ):             # <<<<<<<<<<<<<<
 * 		if self.encoded_keys is not None:
 * 			free( self.encoded_counts )
 */

/* Python wrapper */
static void __pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_2__dealloc__(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_2__dealloc__(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "pomegranate/distributions.pyx":1049
 * 
 * 	def __dealloc__( self ):
 * 		if self.encoded_keys is not None:             # <<<<<<<<<<<<<<
 * 			free( self.encoded_counts )
 * 			free( self.encoded_log_probability )
 */
  __pyx_t_1 = (__pyx_v_self->encoded_keys != ((PyObject*)Py_None));
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pomegranate/distributions.pyx":1050
 * 	def __dealloc__( self ):
 * 		if self.encoded_keys is not None:
 * 			free( self.encoded_counts )             # <<<<<<<<<<<<<<
 * 			free( self.encoded_log_probability )
 * 
 */
    free(__pyx_v_self->encoded_counts);

    /* "pomegranate/distributions.pyx":1051
 * 		if self.encoded_keys is not None:
 * 			free( self.encoded_counts )
 * 			free( self.encoded_log_probability )             # <<<<<<<<<<<<<<
 * 
 * 	def __len__( self ):
 */
    free(__pyx_v_self->encoded_log_probability);

    /* "pomegranate/distributions.pyx":1049
 * 
 * 	def __dealloc__( self ):
 * 		if self.encoded_keys is not None:             # <<<<<<<<<<<<<<
 * 			free( self.encoded_counts )
 * 			free( self.encoded_log_probability )
 */
  }

  /* "pomegranate/distributions.pyx":1048
 * 		self.encoded_log_probability = NULL
 * 
 * 	def __dealloc__( self ):             # <<<<<<<<<<<<<<
 * 		if self.encoded_keys is not None:
 * 			free( self.encoded_counts )
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "pomegranate/distributions.pyx":1053
 * 			free( self.encoded_log_probability )
 * 
 * 	def __len__( self ):             # <<<<<<<<<<<<<<
 * 		"""Return the length of the underlying dictionary"""
 * 		return len( self.dist )
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_5__len__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_4__len__[] = "Return the length of the underlying dictionary";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_11pomegranate_13distributions_20DiscreteDistribution_4__len__;
#endif
static Py_ssize_t __pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_5__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_4__len__(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_4__len__(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "pomegranate/distributions.pyx":1055
 * 	def __len__( self ):
 * 		"""Return the length of the underlying dictionary"""
 * 		return len( self.dist )             # <<<<<<<<<<<<<<
 * 
 * 	def __mul__( self, other ):
 */
  __pyx_t_1 = __pyx_v_self->dist;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyDict_Size(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1053
 * 			free( self.encoded_log_probability )
 * 
 * 	def __len__( self ):             # <<<<<<<<<<<<<<
 * 		"""Return the length of the underlying dictionary"""
 * 		return len( self.dist )
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1057
 * 		return len( self.dist )
 * 
 * 	def __mul__( self, other ):             # <<<<<<<<<<<<<<
 * 		"""Multiply this by another distribution sharing the same keys."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_7__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_6__mul__[] = "Multiply this by another distribution sharing the same keys.";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_11pomegranate_13distributions_20DiscreteDistribution_6__mul__;
#endif
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_7__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__mul__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_6__mul__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_6__mul__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_v_distribution = NULL;
  double __pyx_v_total;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  double __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__mul__", 0);

  /* "pomegranate/distributions.pyx":1060
 * 		"""Multiply this by another distribution sharing the same keys."""
 * 
 * 		assert set( self.keys() ) == set( other.keys() )             # <<<<<<<<<<<<<<
 * 		distribution, total = {}, 0.0
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PySet_New(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_keys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PySet_New(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_5)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "pomegranate/distributions.pyx":1061
 * 
 * 		assert set( self.keys() ) == set( other.keys() )
 * 		distribution, total = {}, 0.0             # <<<<<<<<<<<<<<
 * 
 * 		for key in self.keys():
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = 0.0;
  __pyx_v_distribution = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_total = __pyx_t_6;

  /* "pomegranate/distributions.pyx":1063
 * 		distribution, total = {}, 0.0
 * 
 * 		for key in self.keys():             # <<<<<<<<<<<<<<
 * 			distribution[key] = self.log_probability( key ) + other.log_probability( key )
 * 			total += cexp( distribution[key] )
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_keys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_8(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":1064
 * 
 * 		for key in self.keys():
 * 			distribution[key] = self.log_probability( key ) + other.log_probability( key )             # <<<<<<<<<<<<<<
 * 			total += cexp( distribution[key] )
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_log_probability); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(__pyx_v_key);
      __Pyx_GIVEREF(__pyx_v_key);
      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_key);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_log_probability); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_key); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(__pyx_v_key);
      __Pyx_GIVEREF(__pyx_v_key);
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_key);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(PyDict_SetItem(__pyx_v_distribution, __pyx_v_key, __pyx_t_9) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "pomegranate/distributions.pyx":1065
 * 		for key in self.keys():
 * 			distribution[key] = self.log_probability( key ) + other.log_probability( key )
 * 			total += cexp( distribution[key] )             # <<<<<<<<<<<<<<
 * 
 * 		for key in self.keys():
 */
    __pyx_t_9 = __Pyx_PyDict_GetItem(__pyx_v_distribution, __pyx_v_key); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_v_total = (__pyx_v_total + exp(__pyx_t_6));

    /* "pomegranate/distributions.pyx":1063
 * 		distribution, total = {}, 0.0
 * 
 * 		for key in self.keys():             # <<<<<<<<<<<<<<
 * 			distribution[key] = self.log_probability( key ) + other.log_probability( key )
 * 			total += cexp( distribution[key] )
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":1067
 * 			total += cexp( distribution[key] )
 * 
 * 		for key in self.keys():             # <<<<<<<<<<<<<<
 * 			distribution[key] = cexp( distribution[key] ) / total
 * 
 */
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_keys); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_9 = __pyx_t_3; __Pyx_INCREF(__pyx_t_9); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_8 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_9))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_9)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_9, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_9, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_8(__pyx_t_9);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":1068
 * 
 * 		for key in self.keys():
 * 			distribution[key] = cexp( distribution[key] ) / total             # <<<<<<<<<<<<<<
 * 
 * 		return DiscreteDistribution( distribution )
 */
    __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_distribution, __pyx_v_key); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyFloat_FromDouble((exp(__pyx_t_6) / __pyx_v_total)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(PyDict_SetItem(__pyx_v_distribution, __pyx_v_key, __pyx_t_3) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":1067
 * 			total += cexp( distribution[key] )
 * 
 * 		for key in self.keys():             # <<<<<<<<<<<<<<
 * 			distribution[key] = cexp( distribution[key] ) / total
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "pomegranate/distributions.pyx":1070
 * 			distribution[key] = cexp( distribution[key] ) / total
 * 
 * 		return DiscreteDistribution( distribution )             # <<<<<<<<<<<<<<
 * 
 * 	def equals( self, other ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_v_distribution);
  __Pyx_GIVEREF(__pyx_v_distribution);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_distribution);
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11pomegranate_13distributions_DiscreteDistribution), __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1057
 * 		return len( self.dist )
 * 
 * 	def __mul__( self, other ):             # <<<<<<<<<<<<<<
 * 		"""Multiply this by another distribution sharing the same keys."""
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.__mul__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_distribution);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1072
 * 		return DiscreteDistribution( distribution )
 * 
 * 	def equals( self, other ):             # <<<<<<<<<<<<<<
 * 		"""Return if the keys and values are equal"""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_9equals(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_8equals[] = "Return if the keys and values are equal";
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_9equals(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("equals (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_8equals(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_8equals(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_self_prob = NULL;
  PyObject *__pyx_v_other_prob = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("equals", 0);

  /* "pomegranate/distributions.pyx":1075
 * 		"""Return if the keys and values are equal"""
 * 
 * 		if not isinstance( other, DiscreteDistribution ):             # <<<<<<<<<<<<<<
 * 			return False
 * 
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_11pomegranate_13distributions_DiscreteDistribution); 
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "pomegranate/distributions.pyx":1076
 * 
 * 		if not isinstance( other, DiscreteDistribution ):
 * 			return False             # <<<<<<<<<<<<<<
 * 
 * 		if set( self.keys() ) != set( other.keys() ):
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":1075
 * 		"""Return if the keys and values are equal"""
 * 
 * 		if not isinstance( other, DiscreteDistribution ):             # <<<<<<<<<<<<<<
 * 			return False
 * 
 */
  }

  /* "pomegranate/distributions.pyx":1078
 * 			return False
 * 
 * 		if set( self.keys() ) != set( other.keys() ):             # <<<<<<<<<<<<<<
 * 			return False
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_keys); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PySet_New(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_keys); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PySet_New(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_4, __pyx_t_5, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {

    /* "pomegranate/distributions.pyx":1079
 * 
 * 		if set( self.keys() ) != set( other.keys() ):
 * 			return False             # <<<<<<<<<<<<<<
 * 
 * 		for key in self.keys():
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":1078
 * 			return False
 * 
 * 		if set( self.keys() ) != set( other.keys() ):             # <<<<<<<<<<<<<<
 * 			return False
 * 
 */
  }

  /* "pomegranate/distributions.pyx":1081
 * 			return False
 * 
 * 		for key in self.keys():             # <<<<<<<<<<<<<<
 * 			self_prob = round( self.log_probability( key ), 12 )
 * 			other_prob = round( other.log_probability( key ), 12 )
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_keys); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_5 = __pyx_t_3; __Pyx_INCREF(__pyx_t_5); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_8(__pyx_t_5);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":1082
 * 
 * 		for key in self.keys():
 * 			self_prob = round( self.log_probability( key ), 12 )             # <<<<<<<<<<<<<<
 * 			other_prob = round( other.log_probability( key ), 12 )
 * 			if self_prob != other_prob:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_log_probability); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_key); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_key);
      __Pyx_GIVEREF(__pyx_v_key);
      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_key);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_INCREF(__pyx_int_12);
    __Pyx_GIVEREF(__pyx_int_12);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_12);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_round, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_self_prob, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":1083
 * 		for key in self.keys():
 * 			self_prob = round( self.log_probability( key ), 12 )
 * 			other_prob = round( other.log_probability( key ), 12 )             # <<<<<<<<<<<<<<
 * 			if self_prob != other_prob:
 * 				return False
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_log_probability); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_key); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = NULL;
      __Pyx_INCREF(__pyx_v_key);
      __Pyx_GIVEREF(__pyx_v_key);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_key);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_INCREF(__pyx_int_12);
    __Pyx_GIVEREF(__pyx_int_12);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_12);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_round, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_other_prob, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":1084
 * 			self_prob = round( self.log_probability( key ), 12 )
 * 			other_prob = round( other.log_probability( key ), 12 )
 * 			if self_prob != other_prob:             # <<<<<<<<<<<<<<
 * 				return False
 * 
 */
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_self_prob, __pyx_v_other_prob, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {

      /* "pomegranate/distributions.pyx":1085
 * 			other_prob = round( other.log_probability( key ), 12 )
 * 			if self_prob != other_prob:
 * 				return False             # <<<<<<<<<<<<<<
 * 
 * 		return True
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L0;

      /* "pomegranate/distributions.pyx":1084
 * 			self_prob = round( self.log_probability( key ), 12 )
 * 			other_prob = round( other.log_probability( key ), 12 )
 * 			if self_prob != other_prob:             # <<<<<<<<<<<<<<
 * 				return False
 * 
 */
    }

    /* "pomegranate/distributions.pyx":1081
 * 			return False
 * 
 * 		for key in self.keys():             # <<<<<<<<<<<<<<
 * 			self_prob = round( self.log_probability( key ), 12 )
 * 			other_prob = round( other.log_probability( key ), 12 )
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1087
 * 				return False
 * 
 * 		return True             # <<<<<<<<<<<<<<
 * 
 * 	def clamp( self, key ):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_True);
  __pyx_r = Py_True;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1072
 * 		return DiscreteDistribution( distribution )
 * 
 * 	def equals( self, other ):             # <<<<<<<<<<<<<<
 * 		"""Return if the keys and values are equal"""
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.equals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_self_prob);
  __Pyx_XDECREF(__pyx_v_other_prob);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1089
 * 		return True
 * 
 * 	def clamp( self, key ):             # <<<<<<<<<<<<<<
 * 		"""Return a distribution clamped to a particular value."""
 * 		return DiscreteDistribution( { k : 0. if k != key else 1. for k in self.keys() } )
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_11clamp(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_10clamp[] = "Return a distribution clamped to a particular value.";
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_11clamp(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clamp (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_10clamp(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_key));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_10clamp(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("clamp", 0);

  /* "pomegranate/distributions.pyx":1091
 * 	def clamp( self, key ):
 * 		"""Return a distribution clamped to a particular value."""
 * 		return DiscreteDistribution( { k : 0. if k != key else 1. for k in self.keys() } )             # <<<<<<<<<<<<<<
 * 
 * 	def keys( self ):
 */
  __Pyx_XDECREF(__pyx_r);
  { /* enter inner scope */
    PyObject *__pyx_8genexpr2__pyx_v_k = NULL;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_keys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_6(__pyx_t_3);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_k, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_4 = PyObject_RichCompare(__pyx_8genexpr2__pyx_v_k, __pyx_v_key, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_7) {
        __Pyx_INCREF(__pyx_float_0_);
        __pyx_t_2 = __pyx_float_0_;
      } else {
        __Pyx_INCREF(__pyx_float_1_);
        __pyx_t_2 = __pyx_float_1_;
      }
      if (unlikely(PyDict_SetItem(__pyx_t_1, (PyObject*)__pyx_8genexpr2__pyx_v_k, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_k);
    goto __pyx_L8_exit_scope;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_k);
    goto __pyx_L1_error;
    __pyx_L8_exit_scope:;
  } /* exit inner scope */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11pomegranate_13distributions_DiscreteDistribution), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1089
 * 		return True
 * 
 * 	def clamp( self, key ):             # <<<<<<<<<<<<<<
 * 		"""Return a distribution clamped to a particular value."""
 * 		return DiscreteDistribution( { k : 0. if k != key else 1. for k in self.keys() } )
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.clamp", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1093
 * 		return DiscreteDistribution( { k : 0. if k != key else 1. for k in self.keys() } )
 * 
 * 	def keys( self ):             # <<<<<<<<<<<<<<
 * 		"""Return the keys of the underlying dictionary."""
 * 		return self.dist.keys()
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_13keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_12keys[] = "Return the keys of the underlying dictionary.";
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_13keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("keys (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_12keys(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_12keys(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("keys", 0);

  /* "pomegranate/distributions.pyx":1095
 * 	def keys( self ):
 * 		"""Return the keys of the underlying dictionary."""
 * 		return self.dist.keys()             # <<<<<<<<<<<<<<
 * 
 * 	def items( self ):
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_self->dist == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "keys");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_PyDict_Keys(__pyx_v_self->dist); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1093
 * 		return DiscreteDistribution( { k : 0. if k != key else 1. for k in self.keys() } )
 * 
 * 	def keys( self ):             # <<<<<<<<<<<<<<
 * 		"""Return the keys of the underlying dictionary."""
 * 		return self.dist.keys()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1097
 * 		return self.dist.keys()
 * 
 * 	def items( self ):             # <<<<<<<<<<<<<<
 * 		"""Return items of the underlying dictionary."""
 * 		return self.dist.items()
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_15items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_14items[] = "Return items of the underlying dictionary.";
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_15items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("items (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_14items(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_14items(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("items", 0);

  /* "pomegranate/distributions.pyx":1099
 * 	def items( self ):
 * 		"""Return items of the underlying dictionary."""
 * 		return self.dist.items()             # <<<<<<<<<<<<<<
 * 
 * 	def values( self ):
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_self->dist == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "items");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_PyDict_Items(__pyx_v_self->dist); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1097
 * 		return self.dist.keys()
 * 
 * 	def items( self ):             # <<<<<<<<<<<<<<
 * 		"""Return items of the underlying dictionary."""
 * 		return self.dist.items()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.items", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1101
 * 		return self.dist.items()
 * 
 * 	def values( self ):             # <<<<<<<<<<<<<<
 * 		"""Return values of the underlying dictionary."""
 * 		return self.dist.values()
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_17values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_16values[] = "Return values of the underlying dictionary.";
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_17values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("values (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_16values(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_16values(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("values", 0);

  /* "pomegranate/distributions.pyx":1103
 * 	def values( self ):
 * 		"""Return values of the underlying dictionary."""
 * 		return self.dist.values()             # <<<<<<<<<<<<<<
 * 
 * 	def mle( self ):
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_self->dist == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "values");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_PyDict_Values(__pyx_v_self->dist); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1101
 * 		return self.dist.items()
 * 
 * 	def values( self ):             # <<<<<<<<<<<<<<
 * 		"""Return values of the underlying dictionary."""
 * 		return self.dist.values()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.values", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1105
 * 		return self.dist.values()
 * 
 * 	def mle( self ):             # <<<<<<<<<<<<<<
 * 		"""Return the maximally likely key."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_19mle(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_18mle[] = "Return the maximally likely key.";
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_19mle(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("mle (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_18mle(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_18mle(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self) {
  PyObject *__pyx_v_max_key = NULL;
  PyObject *__pyx_v_max_value = NULL;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("mle", 0);

  /* "pomegranate/distributions.pyx":1108
 * 		"""Return the maximally likely key."""
 * 
 * 		max_key, max_value = None, 0             # <<<<<<<<<<<<<<
 * 		for key, value in self.items():
 * 			if value > max_value:
 */
  __pyx_t_1 = Py_None;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __pyx_int_0;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_max_key = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_max_value = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":1109
 * 
 * 		max_key, max_value = None, 0
 * 		for key, value in self.items():             # <<<<<<<<<<<<<<
 * 			if value > max_value:
 * 				max_key, max_value = key, value
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "pomegranate/distributions.pyx":1110
 * 		max_key, max_value = None, 0
 * 		for key, value in self.items():
 * 			if value > max_value:             # <<<<<<<<<<<<<<
 * 				max_key, max_value = key, value
 * 
 */
    __pyx_t_2 = PyObject_RichCompare(__pyx_v_value, __pyx_v_max_value, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_9) {

      /* "pomegranate/distributions.pyx":1111
 * 		for key, value in self.items():
 * 			if value > max_value:
 * 				max_key, max_value = key, value             # <<<<<<<<<<<<<<
 * 
 * 		return max_key
 */
      __pyx_t_2 = __pyx_v_key;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_6 = __pyx_v_value;
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_DECREF_SET(__pyx_v_max_key, __pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_max_value, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "pomegranate/distributions.pyx":1110
 * 		max_key, max_value = None, 0
 * 		for key, value in self.items():
 * 			if value > max_value:             # <<<<<<<<<<<<<<
 * 				max_key, max_value = key, value
 * 
 */
    }

    /* "pomegranate/distributions.pyx":1109
 * 
 * 		max_key, max_value = None, 0
 * 		for key, value in self.items():             # <<<<<<<<<<<<<<
 * 			if value > max_value:
 * 				max_key, max_value = key, value
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1113
 * 				max_key, max_value = key, value
 * 
 * 		return max_key             # <<<<<<<<<<<<<<
 * 
 * 	def encode( self, encoded_keys ):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_max_key);
  __pyx_r = __pyx_v_max_key;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1105
 * 		return self.dist.values()
 * 
 * 	def mle( self ):             # <<<<<<<<<<<<<<
 * 		"""Return the maximally likely key."""
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.mle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_max_key);
  __Pyx_XDECREF(__pyx_v_max_value);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1115
 * 		return max_key
 * 
 * 	def encode( self, encoded_keys ):             # <<<<<<<<<<<<<<
 * 		"""Encoding the distribution into integers."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_21encode(PyObject *__pyx_v_self, PyObject *__pyx_v_encoded_keys); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_20encode[] = "Encoding the distribution into integers.";
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_21encode(PyObject *__pyx_v_self, PyObject *__pyx_v_encoded_keys) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("encode (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_20encode(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_encoded_keys));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_20encode(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_encoded_keys) {
  Py_ssize_t __pyx_v_n;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  double __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("encode", 0);

  /* "pomegranate/distributions.pyx":1118
 * 		"""Encoding the distribution into integers."""
 * 
 * 		if encoded_keys is None:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_1 = (__pyx_v_encoded_keys == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pomegranate/distributions.pyx":1119
 * 
 * 		if encoded_keys is None:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		n = len(encoded_keys)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":1118
 * 		"""Encoding the distribution into integers."""
 * 
 * 		if encoded_keys is None:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":1121
 * 			return
 * 
 * 		n = len(encoded_keys)             # <<<<<<<<<<<<<<
 * 		self.encoded_keys = encoded_keys
 * 		self.encoded_counts = <double*> calloc( n, sizeof(double) )
 */
  __pyx_t_3 = PyObject_Length(__pyx_v_encoded_keys); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_n = __pyx_t_3;

  /* "pomegranate/distributions.pyx":1122
 * 
 * 		n = len(encoded_keys)
 * 		self.encoded_keys = encoded_keys             # <<<<<<<<<<<<<<
 * 		self.encoded_counts = <double*> calloc( n, sizeof(double) )
 * 		self.encoded_log_probability = <double*> calloc( n, sizeof(double) )
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_encoded_keys))||((__pyx_v_encoded_keys) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_encoded_keys)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __pyx_v_encoded_keys;
  __Pyx_INCREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_GOTREF(__pyx_v_self->encoded_keys);
  __Pyx_DECREF(__pyx_v_self->encoded_keys);
  __pyx_v_self->encoded_keys = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1123
 * 		n = len(encoded_keys)
 * 		self.encoded_keys = encoded_keys
 * 		self.encoded_counts = <double*> calloc( n, sizeof(double) )             # <<<<<<<<<<<<<<
 * 		self.encoded_log_probability = <double*> calloc( n, sizeof(double) )
 * 		self.n = n
 */
  __pyx_v_self->encoded_counts = ((double *)calloc(__pyx_v_n, (sizeof(double))));

  /* "pomegranate/distributions.pyx":1124
 * 		self.encoded_keys = encoded_keys
 * 		self.encoded_counts = <double*> calloc( n, sizeof(double) )
 * 		self.encoded_log_probability = <double*> calloc( n, sizeof(double) )             # <<<<<<<<<<<<<<
 * 		self.n = n
 * 
 */
  __pyx_v_self->encoded_log_probability = ((double *)calloc(__pyx_v_n, (sizeof(double))));

  /* "pomegranate/distributions.pyx":1125
 * 		self.encoded_counts = <double*> calloc( n, sizeof(double) )
 * 		self.encoded_log_probability = <double*> calloc( n, sizeof(double) )
 * 		self.n = n             # <<<<<<<<<<<<<<
 * 
 * 		for i in range(n):
 */
  __pyx_v_self->n = __pyx_v_n;

  /* "pomegranate/distributions.pyx":1127
 * 		self.n = n
 * 
 * 		for i in range(n):             # <<<<<<<<<<<<<<
 * 			key = encoded_keys[i]
 * 			self.encoded_counts[i] = 0
 */
  __pyx_t_3 = __pyx_v_n;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "pomegranate/distributions.pyx":1128
 * 
 * 		for i in range(n):
 * 			key = encoded_keys[i]             # <<<<<<<<<<<<<<
 * 			self.encoded_counts[i] = 0
 * 			self.encoded_log_probability[i] = self.log_dist.get( key, NEGINF )
 */
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_encoded_keys, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 0); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1128; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":1129
 * 		for i in range(n):
 * 			key = encoded_keys[i]
 * 			self.encoded_counts[i] = 0             # <<<<<<<<<<<<<<
 * 			self.encoded_log_probability[i] = self.log_dist.get( key, NEGINF )
 * 
 */
    (__pyx_v_self->encoded_counts[__pyx_v_i]) = 0.0;

    /* "pomegranate/distributions.pyx":1130
 * 			key = encoded_keys[i]
 * 			self.encoded_counts[i] = 0
 * 			self.encoded_log_probability[i] = self.log_dist.get( key, NEGINF )             # <<<<<<<<<<<<<<
 * 
 * 	def log_probability( self, symbol ):
 */
    if (unlikely(__pyx_v_self->log_dist == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_4 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->log_dist, __pyx_v_key, __pyx_float_neg_inf); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    (__pyx_v_self->encoded_log_probability[__pyx_v_i]) = __pyx_t_6;
  }

  /* "pomegranate/distributions.pyx":1115
 * 		return max_key
 * 
 * 	def encode( self, encoded_keys ):             # <<<<<<<<<<<<<<
 * 		"""Encoding the distribution into integers."""
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1132
 * 			self.encoded_log_probability[i] = self.log_dist.get( key, NEGINF )
 * 
 * 	def log_probability( self, symbol ):             # <<<<<<<<<<<<<<
 * 		"""Return the log prob of the symbol under this distribution."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_23log_probability(PyObject *__pyx_v_self, PyObject *__pyx_v_symbol); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_22log_probability[] = "Return the log prob of the symbol under this distribution.";
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_23log_probability(PyObject *__pyx_v_self, PyObject *__pyx_v_symbol) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("log_probability (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_22log_probability(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_symbol));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_22log_probability(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_symbol) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("log_probability", 0);

  /* "pomegranate/distributions.pyx":1135
 * 		"""Return the log prob of the symbol under this distribution."""
 * 
 * 		return self.__log_probability( symbol )             # <<<<<<<<<<<<<<
 * 
 * 	cdef double __log_probability( self, symbol ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx___log_probability(__pyx_v_self, __pyx_v_symbol)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1132
 * 			self.encoded_log_probability[i] = self.log_dist.get( key, NEGINF )
 * 
 * 	def log_probability( self, symbol ):             # <<<<<<<<<<<<<<
 * 		"""Return the log prob of the symbol under this distribution."""
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.log_probability", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1137
 * 		return self.__log_probability( symbol )
 * 
 * 	cdef double __log_probability( self, symbol ):             # <<<<<<<<<<<<<<
 * 		"""Cython optimized lookup."""
 * 
 */

static double __pyx_f_11pomegranate_13distributions_20DiscreteDistribution___log_probability(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_symbol) {
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  double __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__log_probability", 0);

  /* "pomegranate/distributions.pyx":1140
 * 		"""Cython optimized lookup."""
 * 
 * 		return self.log_dist.get( symbol, NEGINF )             # <<<<<<<<<<<<<<
 * 
 * 	cdef public double _log_probability( self, double symbol ) nogil:
 */
  if (unlikely(__pyx_v_self->log_dist == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->log_dist, __pyx_v_symbol, __pyx_float_neg_inf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1137
 * 		return self.__log_probability( symbol )
 * 
 * 	cdef double __log_probability( self, symbol ):             # <<<<<<<<<<<<<<
 * 		"""Cython optimized lookup."""
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_WriteUnraisable("pomegranate.distributions.DiscreteDistribution.__log_probability", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1142
 * 		return self.log_dist.get( symbol, NEGINF )
 * 
 * 	cdef public double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized lookup."""
 * 
 */

static double __pyx_f_11pomegranate_13distributions_20DiscreteDistribution__log_probability(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, double __pyx_v_symbol) {
  double __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;

  /* "pomegranate/distributions.pyx":1145
 * 		"""Cython optimized lookup."""
 * 
 * 		if symbol < 0 or symbol > self.n:             # <<<<<<<<<<<<<<
 * 			return NEGINF
 * 		return self.encoded_log_probability[<SIZE_t> symbol]
 */
  __pyx_t_2 = ((__pyx_v_symbol < 0.0) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_symbol > __pyx_v_self->n) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":1146
 * 
 * 		if symbol < 0 or symbol > self.n:
 * 			return NEGINF             # <<<<<<<<<<<<<<
 * 		return self.encoded_log_probability[<SIZE_t> symbol]
 * 
 */
    __pyx_r = (-Py_HUGE_VAL);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":1145
 * 		"""Cython optimized lookup."""
 * 
 * 		if symbol < 0 or symbol > self.n:             # <<<<<<<<<<<<<<
 * 			return NEGINF
 * 		return self.encoded_log_probability[<SIZE_t> symbol]
 */
  }

  /* "pomegranate/distributions.pyx":1147
 * 		if symbol < 0 or symbol > self.n:
 * 			return NEGINF
 * 		return self.encoded_log_probability[<SIZE_t> symbol]             # <<<<<<<<<<<<<<
 * 
 * 	def sample( self ):
 */
  __pyx_r = (__pyx_v_self->encoded_log_probability[((__pyx_t_11pomegranate_13distributions_SIZE_t)__pyx_v_symbol)]);
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1142
 * 		return self.log_dist.get( symbol, NEGINF )
 * 
 * 	cdef public double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized lookup."""
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1149
 * 		return self.encoded_log_probability[<SIZE_t> symbol]
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""Sample randomly from the discrete distribution."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_25sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_24sample[] = "Sample randomly from the discrete distribution.";
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_25sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_24sample(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_24sample(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self) {
  PyObject *__pyx_v_rand = NULL;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);

  /* "pomegranate/distributions.pyx":1152
 * 		"""Sample randomly from the discrete distribution."""
 * 
 * 		rand = random.random()             # <<<<<<<<<<<<<<
 * 		for key, value in self.items():
 * 			if value >= rand:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_rand = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1153
 * 
 * 		rand = random.random()
 * 		for key, value in self.items():             # <<<<<<<<<<<<<<
 * 			if value >= rand:
 * 				return key
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_items); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_2 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "pomegranate/distributions.pyx":1154
 * 		rand = random.random()
 * 		for key, value in self.items():
 * 			if value >= rand:             # <<<<<<<<<<<<<<
 * 				return key
 * 			rand -= value
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_value, __pyx_v_rand, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_9) {

      /* "pomegranate/distributions.pyx":1155
 * 		for key, value in self.items():
 * 			if value >= rand:
 * 				return key             # <<<<<<<<<<<<<<
 * 			rand -= value
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_key);
      __pyx_r = __pyx_v_key;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L0;

      /* "pomegranate/distributions.pyx":1154
 * 		rand = random.random()
 * 		for key, value in self.items():
 * 			if value >= rand:             # <<<<<<<<<<<<<<
 * 				return key
 * 			rand -= value
 */
    }

    /* "pomegranate/distributions.pyx":1156
 * 			if value >= rand:
 * 				return key
 * 			rand -= value             # <<<<<<<<<<<<<<
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0 ):
 */
    __pyx_t_1 = PyNumber_InPlaceSubtract(__pyx_v_rand, __pyx_v_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_rand, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":1153
 * 
 * 		rand = random.random()
 * 		for key, value in self.items():             # <<<<<<<<<<<<<<
 * 			if value >= rand:
 * 				return key
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":1149
 * 		return self.encoded_log_probability[<SIZE_t> symbol]
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""Sample randomly from the discrete distribution."""
 * 
 */

  /* function exit code */
  __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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_rand);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1158
 * 			rand -= value
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_27from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_26from_sample[] = "\n\t\tSet the parameters of this Distribution to maximize the likelihood of \n\t\tthe given sample. Items holds some sort of sequence. If weights is \n\t\tspecified, it holds a sequence of value to weight each item by.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_27from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,&__pyx_n_s_inertia,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_inertia = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_sample", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_26from_sample(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights, __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_26from_sample(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_sample", 0);

  /* "pomegranate/distributions.pyx":1165
 * 		"""
 * 
 * 		if self.frozen:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_1 = (__pyx_v_self->__pyx_base.frozen != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":1166
 * 
 * 		if self.frozen:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		self.summarize( items, weights )
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":1165
 * 		"""
 * 
 * 		if self.frozen:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":1168
 * 			return
 * 
 * 		self.summarize( items, weights )             # <<<<<<<<<<<<<<
 * 		self.from_summaries( inertia )
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_summarize); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_4) {
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  }
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_weights);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":1169
 * 
 * 		self.summarize( items, weights )
 * 		self.from_summaries( inertia )             # <<<<<<<<<<<<<<
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_summaries); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_inertia); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_INCREF(__pyx_v_inertia);
    __Pyx_GIVEREF(__pyx_v_inertia);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_inertia);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":1158
 * 			rand -= value
 * 
 * 	def from_sample (self, items, weights=None, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1171
 * 		self.from_summaries( inertia )
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython version of summarize."""
 * 
 */

static void __pyx_f_11pomegranate_13distributions_20DiscreteDistribution__summarize(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, double *__pyx_v_items, double *__pyx_v_weights, __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n) {
  int __pyx_v_i;
  double *__pyx_v_encoded_counts;
  __Pyx_RefNannyDeclarations
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_1;
  int __pyx_t_2;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_summarize", 0);
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif

  /* "pomegranate/distributions.pyx":1172
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 * 		"""Cython version of summarize."""             # <<<<<<<<<<<<<<
 * 
 * 		cdef int i
 */
  /*try:*/ {

    /* "pomegranate/distributions.pyx":1175
 * 
 * 		cdef int i
 * 		self.encoded_summary = 1             # <<<<<<<<<<<<<<
 * 
 * 		encoded_counts = <double*> calloc( self.n, sizeof(double) )
 */
    __pyx_v_self->encoded_summary = 1;

    /* "pomegranate/distributions.pyx":1177
 * 		self.encoded_summary = 1
 * 
 * 		encoded_counts = <double*> calloc( self.n, sizeof(double) )             # <<<<<<<<<<<<<<
 * 		memset( encoded_counts, 0, self.n*sizeof(double) )
 * 
 */
    __pyx_v_encoded_counts = ((double *)calloc(__pyx_v_self->n, (sizeof(double))));

    /* "pomegranate/distributions.pyx":1178
 * 
 * 		encoded_counts = <double*> calloc( self.n, sizeof(double) )
 * 		memset( encoded_counts, 0, self.n*sizeof(double) )             # <<<<<<<<<<<<<<
 * 
 * 		for i in range(n):
 */
    memset(__pyx_v_encoded_counts, 0, (__pyx_v_self->n * (sizeof(double))));

    /* "pomegranate/distributions.pyx":1180
 * 		memset( encoded_counts, 0, self.n*sizeof(double) )
 * 
 * 		for i in range(n):             # <<<<<<<<<<<<<<
 * 			encoded_counts[<SIZE_t> items[i]] += weights[i]
 * 
 */
    __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;

      /* "pomegranate/distributions.pyx":1181
 * 
 * 		for i in range(n):
 * 			encoded_counts[<SIZE_t> items[i]] += weights[i]             # <<<<<<<<<<<<<<
 * 
 * 		with gil:
 */
      __pyx_t_3 = ((__pyx_t_11pomegranate_13distributions_SIZE_t)(__pyx_v_items[__pyx_v_i]));
      (__pyx_v_encoded_counts[__pyx_t_3]) = ((__pyx_v_encoded_counts[__pyx_t_3]) + (__pyx_v_weights[__pyx_v_i]));
    }

    /* "pomegranate/distributions.pyx":1183
 * 			encoded_counts[<SIZE_t> items[i]] += weights[i]
 * 
 * 		with gil:             # <<<<<<<<<<<<<<
 * 			for i in range(self.n):
 * 				self.encoded_counts[i] += encoded_counts[i]
 */
    {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        /*try:*/ {

          /* "pomegranate/distributions.pyx":1184
 * 
 * 		with gil:
 * 			for i in range(self.n):             # <<<<<<<<<<<<<<
 * 				self.encoded_counts[i] += encoded_counts[i]
 * 
 */
          __pyx_t_2 = __pyx_v_self->n;
          for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_2; __pyx_t_4+=1) {
            __pyx_v_i = __pyx_t_4;

            /* "pomegranate/distributions.pyx":1185
 * 		with gil:
 * 			for i in range(self.n):
 * 				self.encoded_counts[i] += encoded_counts[i]             # <<<<<<<<<<<<<<
 * 
 * 		free( encoded_counts )
 */
            __pyx_t_5 = __pyx_v_i;
            (__pyx_v_self->encoded_counts[__pyx_t_5]) = ((__pyx_v_self->encoded_counts[__pyx_t_5]) + (__pyx_v_encoded_counts[__pyx_v_i]));
          }
        }

        /* "pomegranate/distributions.pyx":1183
 * 			encoded_counts[<SIZE_t> items[i]] += weights[i]
 * 
 * 		with gil:             # <<<<<<<<<<<<<<
 * 			for i in range(self.n):
 * 				self.encoded_counts[i] += encoded_counts[i]
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            goto __pyx_L10;
          }
          __pyx_L10:;
        }
    }

    /* "pomegranate/distributions.pyx":1187
 * 				self.encoded_counts[i] += encoded_counts[i]
 * 
 * 		free( encoded_counts )             # <<<<<<<<<<<<<<
 * 
 * 	def summarize( self, items, weights=None ):
 */
    free(__pyx_v_encoded_counts);
  }

  /* "pomegranate/distributions.pyx":1172
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 * 		"""Cython version of summarize."""             # <<<<<<<<<<<<<<
 * 
 * 		cdef int i
 */
  /*finally:*/ {
    /*normal exit:*/{
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "pomegranate/distributions.pyx":1171
 * 		self.from_summaries( inertia )
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython version of summarize."""
 * 
 */

  /* function exit code */
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
}

/* "pomegranate/distributions.pyx":1189
 * 		free( encoded_counts )
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""Reduce a set of obervations to sufficient statistics."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_29summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_28summarize[] = "Reduce a set of obervations to sufficient statistics.";
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_29summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("summarize (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "summarize") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("summarize", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_28summarize(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_28summarize(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights) {
  PyObject *__pyx_v_characters = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("summarize", 0);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":1192
 * 		"""Reduce a set of obervations to sufficient statistics."""
 * 
 * 		if weights is None:             # <<<<<<<<<<<<<<
 * 			weights = numpy.ones( len(items) )
 * 
 */
  __pyx_t_1 = (__pyx_v_weights == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pomegranate/distributions.pyx":1193
 * 
 * 		if weights is None:
 * 			weights = numpy.ones( len(items) )             # <<<<<<<<<<<<<<
 * 
 * 		characters = self.summaries[0]
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ones); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":1192
 * 		"""Reduce a set of obervations to sufficient statistics."""
 * 
 * 		if weights is None:             # <<<<<<<<<<<<<<
 * 			weights = numpy.ones( len(items) )
 * 
 */
  }

  /* "pomegranate/distributions.pyx":1195
 * 			weights = numpy.ones( len(items) )
 * 
 * 		characters = self.summaries[0]             # <<<<<<<<<<<<<<
 * 		for i in xrange( len(items) ):
 * 			characters[items[i]] += weights[i]
 */
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 0);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_v_characters = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":1196
 * 
 * 		characters = self.summaries[0]
 * 		for i in xrange( len(items) ):             # <<<<<<<<<<<<<<
 * 			characters[items[i]] += weights[i]
 * 
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_xrange); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_5 = __pyx_t_3; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_9)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_9(__pyx_t_5);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":1197
 * 		characters = self.summaries[0]
 * 		for i in xrange( len(items) ):
 * 			characters[items[i]] += weights[i]             # <<<<<<<<<<<<<<
 * 
 * 	def from_summaries( self, inertia=0.0 ):
 */
    __pyx_t_3 = PyObject_GetItem(__pyx_v_items, __pyx_v_i); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyObject_GetItem(__pyx_v_characters, __pyx_t_3); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyObject_GetItem(__pyx_v_weights, __pyx_v_i); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(PyObject_SetItem(__pyx_v_characters, __pyx_t_3, __pyx_t_4) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":1196
 * 
 * 		characters = self.summaries[0]
 * 		for i in xrange( len(items) ):             # <<<<<<<<<<<<<<
 * 			characters[items[i]] += weights[i]
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1189
 * 		free( encoded_counts )
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""Reduce a set of obervations to sufficient statistics."""
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_characters);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1199
 * 			characters[items[i]] += weights[i]
 * 
 * 	def from_summaries( self, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""Use the summaries in order to update the distribution."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_31from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_30from_summaries[] = "Use the summaries in order to update the distribution.";
static PyObject *__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_31from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_summaries (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_inertia,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_summaries") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_inertia = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_summaries", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_30from_summaries(((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)__pyx_v_self), __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_20DiscreteDistribution_30from_summaries(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *__pyx_v_self, PyObject *__pyx_v_inertia) {
  PyObject *__pyx_v__sum = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_characters = NULL;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_value = NULL;
  Py_ssize_t __pyx_v_n;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  double __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_summaries", 0);

  /* "pomegranate/distributions.pyx":1202
 * 		"""Use the summaries in order to update the distribution."""
 * 
 * 		if self.encoded_summary == 0:             # <<<<<<<<<<<<<<
 * 			_sum = sum( self.summaries[0].values() )
 * 			characters = {}
 */
  __pyx_t_1 = ((__pyx_v_self->encoded_summary == 0) != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":1203
 * 
 * 		if self.encoded_summary == 0:
 * 			_sum = sum( self.summaries[0].values() )             # <<<<<<<<<<<<<<
 * 			characters = {}
 * 			for key, value in self.summaries[0].items():
 */
    if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 0), __pyx_n_s_values); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v__sum = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "pomegranate/distributions.pyx":1204
 * 		if self.encoded_summary == 0:
 * 			_sum = sum( self.summaries[0].values() )
 * 			characters = {}             # <<<<<<<<<<<<<<
 * 			for key, value in self.summaries[0].items():
 * 				self.dist[key] = self.dist[key]*inertia + (1-inertia)*value / _sum
 */
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_characters = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "pomegranate/distributions.pyx":1205
 * 			_sum = sum( self.summaries[0].values() )
 * 			characters = {}
 * 			for key, value in self.summaries[0].items():             # <<<<<<<<<<<<<<
 * 				self.dist[key] = self.dist[key]*inertia + (1-inertia)*value / _sum
 * 				self.log_dist[key] = _log( self.dist[key] )
 */
    if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(PyList_GET_ITEM(__pyx_v_self->__pyx_base.summaries, 0), __pyx_n_s_items); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_6(__pyx_t_3);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_7);
        #else
        __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
        index = 0; __pyx_t_4 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L7_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "pomegranate/distributions.pyx":1206
 * 			characters = {}
 * 			for key, value in self.summaries[0].items():
 * 				self.dist[key] = self.dist[key]*inertia + (1-inertia)*value / _sum             # <<<<<<<<<<<<<<
 * 				self.log_dist[key] = _log( self.dist[key] )
 * 
 */
      if (unlikely(__pyx_v_self->dist == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->dist, __pyx_v_key); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = PyNumber_Multiply(__pyx_t_2, __pyx_v_inertia); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_inertia, 1, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyNumber_Multiply(__pyx_t_2, __pyx_v_value); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_v__sum); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyNumber_Add(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(__pyx_v_self->dist == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (unlikely(PyDict_SetItem(__pyx_v_self->dist, __pyx_v_key, __pyx_t_4) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "pomegranate/distributions.pyx":1207
 * 			for key, value in self.summaries[0].items():
 * 				self.dist[key] = self.dist[key]*inertia + (1-inertia)*value / _sum
 * 				self.log_dist[key] = _log( self.dist[key] )             # <<<<<<<<<<<<<<
 * 
 * 			self.summaries = [{ key: 0 for key in self.keys() }]
 */
      if (unlikely(__pyx_v_self->dist == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_self->dist, __pyx_v_key); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyFloat_FromDouble(__pyx_f_11pomegranate_5utils__log(__pyx_t_10)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      if (unlikely(__pyx_v_self->log_dist == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (unlikely(PyDict_SetItem(__pyx_v_self->log_dist, __pyx_v_key, __pyx_t_4) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "pomegranate/distributions.pyx":1205
 * 			_sum = sum( self.summaries[0].values() )
 * 			characters = {}
 * 			for key, value in self.summaries[0].items():             # <<<<<<<<<<<<<<
 * 				self.dist[key] = self.dist[key]*inertia + (1-inertia)*value / _sum
 * 				self.log_dist[key] = _log( self.dist[key] )
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":1209
 * 				self.log_dist[key] = _log( self.dist[key] )
 * 
 * 			self.summaries = [{ key: 0 for key in self.keys() }]             # <<<<<<<<<<<<<<
 * 			self.encode( self.encoded_keys )
 * 		else:
 */
    { /* enter inner scope */
      PyObject *__pyx_8genexpr3__pyx_v_key = NULL;
      __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      if (__pyx_t_7) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
      }
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
        __pyx_t_2 = __pyx_t_4; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
        __pyx_t_6 = NULL;
      } else {
        __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      for (;;) {
        if (likely(!__pyx_t_6)) {
          if (likely(PyList_CheckExact(__pyx_t_2))) {
            if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
            #else
            __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
            __Pyx_GOTREF(__pyx_t_4);
            #endif
          } else {
            if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
            #else
            __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
            __Pyx_GOTREF(__pyx_t_4);
            #endif
          }
        } else {
          __pyx_t_4 = __pyx_t_6(__pyx_t_2);
          if (unlikely(!__pyx_t_4)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_XDECREF_SET(__pyx_8genexpr3__pyx_v_key, __pyx_t_4);
        __pyx_t_4 = 0;
        if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_8genexpr3__pyx_v_key, (PyObject*)__pyx_int_0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_key);
      goto __pyx_L13_exit_scope;
      __pyx_L10_error:;
      __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_key);
      goto __pyx_L1_error;
      __pyx_L13_exit_scope:;
    } /* exit inner scope */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.summaries);
    __Pyx_DECREF(__pyx_v_self->__pyx_base.summaries);
    __pyx_v_self->__pyx_base.summaries = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "pomegranate/distributions.pyx":1210
 * 
 * 			self.summaries = [{ key: 0 for key in self.keys() }]
 * 			self.encode( self.encoded_keys )             # <<<<<<<<<<<<<<
 * 		else:
 * 			n = len(self.encoded_keys)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->encoded_keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(__pyx_v_self->encoded_keys);
      __Pyx_GIVEREF(__pyx_v_self->encoded_keys);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_self->encoded_keys);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pomegranate/distributions.pyx":1202
 * 		"""Use the summaries in order to update the distribution."""
 * 
 * 		if self.encoded_summary == 0:             # <<<<<<<<<<<<<<
 * 			_sum = sum( self.summaries[0].values() )
 * 			characters = {}
 */
    goto __pyx_L3;
  }

  /* "pomegranate/distributions.pyx":1212
 * 			self.encode( self.encoded_keys )
 * 		else:
 * 			n = len(self.encoded_keys)             # <<<<<<<<<<<<<<
 * 			_sum = 0
 * 			for i in range(n):
 */
  /*else*/ {
    __pyx_t_2 = __pyx_v_self->encoded_keys;
    __Pyx_INCREF(__pyx_t_2);
    if (unlikely(__pyx_t_2 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_5 = PyTuple_GET_SIZE(__pyx_t_2); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_n = __pyx_t_5;

    /* "pomegranate/distributions.pyx":1213
 * 		else:
 * 			n = len(self.encoded_keys)
 * 			_sum = 0             # <<<<<<<<<<<<<<
 * 			for i in range(n):
 * 				_sum += self.encoded_counts[i]
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_v__sum = __pyx_int_0;

    /* "pomegranate/distributions.pyx":1214
 * 			n = len(self.encoded_keys)
 * 			_sum = 0
 * 			for i in range(n):             # <<<<<<<<<<<<<<
 * 				_sum += self.encoded_counts[i]
 * 			for i in range(n):
 */
    __pyx_t_5 = __pyx_v_n;
    for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_5; __pyx_t_11+=1) {
      __pyx_v_i = __pyx_t_11;

      /* "pomegranate/distributions.pyx":1215
 * 			_sum = 0
 * 			for i in range(n):
 * 				_sum += self.encoded_counts[i]             # <<<<<<<<<<<<<<
 * 			for i in range(n):
 * 				key = self.encoded_keys[i]
 */
      __pyx_t_2 = PyFloat_FromDouble((__pyx_v_self->encoded_counts[__pyx_v_i])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v__sum, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v__sum, __pyx_t_3);
      __pyx_t_3 = 0;
    }

    /* "pomegranate/distributions.pyx":1216
 * 			for i in range(n):
 * 				_sum += self.encoded_counts[i]
 * 			for i in range(n):             # <<<<<<<<<<<<<<
 * 				key = self.encoded_keys[i]
 * 				self.dist[key] = (self.dist[key]*inertia +
 */
    __pyx_t_5 = __pyx_v_n;
    for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_5; __pyx_t_11+=1) {
      __pyx_v_i = __pyx_t_11;

      /* "pomegranate/distributions.pyx":1217
 * 				_sum += self.encoded_counts[i]
 * 			for i in range(n):
 * 				key = self.encoded_keys[i]             # <<<<<<<<<<<<<<
 * 				self.dist[key] = (self.dist[key]*inertia +
 * 					(1-inertia)*self.encoded_counts[i] / _sum)
 */
      if (unlikely(__pyx_v_self->encoded_keys == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_self->encoded_keys, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pomegranate/distributions.pyx":1218
 * 			for i in range(n):
 * 				key = self.encoded_keys[i]
 * 				self.dist[key] = (self.dist[key]*inertia +             # <<<<<<<<<<<<<<
 * 					(1-inertia)*self.encoded_counts[i] / _sum)
 * 				self.log_dist[key] = _log( self.dist[key] )
 */
      if (unlikely(__pyx_v_self->dist == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_self->dist, __pyx_v_key); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyNumber_Multiply(__pyx_t_3, __pyx_v_inertia); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pomegranate/distributions.pyx":1219
 * 				key = self.encoded_keys[i]
 * 				self.dist[key] = (self.dist[key]*inertia +
 * 					(1-inertia)*self.encoded_counts[i] / _sum)             # <<<<<<<<<<<<<<
 * 				self.log_dist[key] = _log( self.dist[key] )
 * 				self.encoded_counts[i] = 0
 */
      __pyx_t_3 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_inertia, 1, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = PyFloat_FromDouble((__pyx_v_self->encoded_counts[__pyx_v_i])); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_v__sum); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "pomegranate/distributions.pyx":1218
 * 			for i in range(n):
 * 				key = self.encoded_keys[i]
 * 				self.dist[key] = (self.dist[key]*inertia +             # <<<<<<<<<<<<<<
 * 					(1-inertia)*self.encoded_counts[i] / _sum)
 * 				self.log_dist[key] = _log( self.dist[key] )
 */
      __pyx_t_4 = PyNumber_Add(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(__pyx_v_self->dist == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (unlikely(PyDict_SetItem(__pyx_v_self->dist, __pyx_v_key, __pyx_t_4) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "pomegranate/distributions.pyx":1220
 * 				self.dist[key] = (self.dist[key]*inertia +
 * 					(1-inertia)*self.encoded_counts[i] / _sum)
 * 				self.log_dist[key] = _log( self.dist[key] )             # <<<<<<<<<<<<<<
 * 				self.encoded_counts[i] = 0
 * 
 */
      if (unlikely(__pyx_v_self->dist == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_self->dist, __pyx_v_key); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyFloat_FromDouble(__pyx_f_11pomegranate_5utils__log(__pyx_t_10)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      if (unlikely(__pyx_v_self->log_dist == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (unlikely(PyDict_SetItem(__pyx_v_self->log_dist, __pyx_v_key, __pyx_t_4) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "pomegranate/distributions.pyx":1221
 * 					(1-inertia)*self.encoded_counts[i] / _sum)
 * 				self.log_dist[key] = _log( self.dist[key] )
 * 				self.encoded_counts[i] = 0             # <<<<<<<<<<<<<<
 * 
 * 			self.encode( self.encoded_keys )
 */
      (__pyx_v_self->encoded_counts[__pyx_v_i]) = 0.0;
    }

    /* "pomegranate/distributions.pyx":1223
 * 				self.encoded_counts[i] = 0
 * 
 * 			self.encode( self.encoded_keys )             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_encode); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_2 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_2) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_self->encoded_keys); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_INCREF(__pyx_v_self->encoded_keys);
      __Pyx_GIVEREF(__pyx_v_self->encoded_keys);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_self->encoded_keys);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "pomegranate/distributions.pyx":1199
 * 			characters[items[i]] += weights[i]
 * 
 * 	def from_summaries( self, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""Use the summaries in order to update the distribution."""
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pomegranate.distributions.DiscreteDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__sum);
  __Pyx_XDECREF(__pyx_v_characters);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1240
 * 	"""
 * 
 * 	def __init__(self, lambda_funct, frozen=True ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Takes in a lambda function and stores it. This function should return
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_18LambdaDistribution_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_18LambdaDistribution___init__[] = "\n\t\tTakes in a lambda function and stores it. This function should return\n\t\tthe log probability of seeing a certain input.\n\t\t";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_11pomegranate_13distributions_18LambdaDistribution___init__;
#endif
static int __pyx_pw_11pomegranate_13distributions_18LambdaDistribution_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_lambda_funct = 0;
  PyObject *__pyx_v_frozen = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_lambda_funct,&__pyx_n_s_frozen,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_lambda_funct)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_lambda_funct = values[0];
    __pyx_v_frozen = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.LambdaDistribution.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_18LambdaDistribution___init__(((struct __pyx_obj_11pomegranate_13distributions_LambdaDistribution *)__pyx_v_self), __pyx_v_lambda_funct, __pyx_v_frozen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_18LambdaDistribution___init__(struct __pyx_obj_11pomegranate_13distributions_LambdaDistribution *__pyx_v_self, PyObject *__pyx_v_lambda_funct, PyObject *__pyx_v_frozen) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pomegranate/distributions.pyx":1247
 * 
 * 		# Store the parameters
 * 		self.parameters = [lambda_funct]             # <<<<<<<<<<<<<<
 * 		self.name = "LambdaDistribution"
 * 		self.frozen = frozen
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_lambda_funct);
  __Pyx_GIVEREF(__pyx_v_lambda_funct);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_lambda_funct);
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1248
 * 		# Store the parameters
 * 		self.parameters = [lambda_funct]
 * 		self.name = "LambdaDistribution"             # <<<<<<<<<<<<<<
 * 		self.frozen = frozen
 * 
 */
  __Pyx_INCREF(__pyx_n_s_LambdaDistribution);
  __Pyx_GIVEREF(__pyx_n_s_LambdaDistribution);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.name);
  __pyx_v_self->__pyx_base.name = __pyx_n_s_LambdaDistribution;

  /* "pomegranate/distributions.pyx":1249
 * 		self.parameters = [lambda_funct]
 * 		self.name = "LambdaDistribution"
 * 		self.frozen = frozen             # <<<<<<<<<<<<<<
 * 
 * 	def log_probability(self, symbol):
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_frozen); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->__pyx_base.frozen = __pyx_t_2;

  /* "pomegranate/distributions.pyx":1240
 * 	"""
 * 
 * 	def __init__(self, lambda_funct, frozen=True ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Takes in a lambda function and stores it. This function should return
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.LambdaDistribution.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1251
 * 		self.frozen = frozen
 * 
 * 	def log_probability(self, symbol):             # <<<<<<<<<<<<<<
 * 		"""
 * 		What's the probability of the given float under this distribution?
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_18LambdaDistribution_3log_probability(PyObject *__pyx_v_self, PyObject *__pyx_v_symbol); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_18LambdaDistribution_2log_probability[] = "\n\t\tWhat's the probability of the given float under this distribution?\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_18LambdaDistribution_3log_probability(PyObject *__pyx_v_self, PyObject *__pyx_v_symbol) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("log_probability (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_18LambdaDistribution_2log_probability(((struct __pyx_obj_11pomegranate_13distributions_LambdaDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_symbol));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_18LambdaDistribution_2log_probability(struct __pyx_obj_11pomegranate_13distributions_LambdaDistribution *__pyx_v_self, PyObject *__pyx_v_symbol) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("log_probability", 0);

  /* "pomegranate/distributions.pyx":1256
 * 		"""
 * 
 * 		return self.parameters[0](symbol)             # <<<<<<<<<<<<<<
 * 
 * cdef class KernelDensity( Distribution ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1256; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_symbol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_symbol);
    __Pyx_GIVEREF(__pyx_v_symbol);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_symbol);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1251
 * 		self.frozen = frozen
 * 
 * 	def log_probability(self, symbol):             # <<<<<<<<<<<<<<
 * 		"""
 * 		What's the probability of the given float under this distribution?
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pomegranate.distributions.LambdaDistribution.log_probability", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1262
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [ self.points_ndarray.tolist(), self.bandwidth, self.weights_ndarray.tolist() ]
 * 		def __set__( self, parameters ):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_13KernelDensity_10parameters_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_13KernelDensity_10parameters_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_13KernelDensity_10parameters___get__(((struct __pyx_obj_11pomegranate_13distributions_KernelDensity *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_13KernelDensity_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_KernelDensity *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pomegranate/distributions.pyx":1263
 * 	property parameters:
 * 		def __get__( self ):
 * 			return [ self.points_ndarray.tolist(), self.bandwidth, self.weights_ndarray.tolist() ]             # <<<<<<<<<<<<<<
 * 		def __set__( self, parameters ):
 * 			self.points_ndarray = numpy.array( parameters[0] )
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->points_ndarray), __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->bandwidth); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->weights_ndarray), __pyx_n_s_tolist); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1262
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [ self.points_ndarray.tolist(), self.bandwidth, self.weights_ndarray.tolist() ]
 * 		def __set__( self, parameters ):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pomegranate.distributions.KernelDensity.parameters.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1264
 * 		def __get__( self ):
 * 			return [ self.points_ndarray.tolist(), self.bandwidth, self.weights_ndarray.tolist() ]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.points_ndarray = numpy.array( parameters[0] )
 * 			self.points = <double*> self.points_ndarray.data
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_13KernelDensity_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_13KernelDensity_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_13KernelDensity_10parameters_2__set__(((struct __pyx_obj_11pomegranate_13distributions_KernelDensity *)__pyx_v_self), ((PyObject *)__pyx_v_parameters));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_13KernelDensity_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_KernelDensity *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "pomegranate/distributions.pyx":1265
 * 			return [ self.points_ndarray.tolist(), self.bandwidth, self.weights_ndarray.tolist() ]
 * 		def __set__( self, parameters ):
 * 			self.points_ndarray = numpy.array( parameters[0] )             # <<<<<<<<<<<<<<
 * 			self.points = <double*> self.points_ndarray.data
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_parameters, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->points_ndarray);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->points_ndarray));
  __pyx_v_self->points_ndarray = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1266
 * 		def __set__( self, parameters ):
 * 			self.points_ndarray = numpy.array( parameters[0] )
 * 			self.points = <double*> self.points_ndarray.data             # <<<<<<<<<<<<<<
 * 
 * 			self.bandwidth = parameters[1]
 */
  __pyx_v_self->points = ((double *)__pyx_v_self->points_ndarray->data);

  /* "pomegranate/distributions.pyx":1268
 * 			self.points = <double*> self.points_ndarray.data
 * 
 * 			self.bandwidth = parameters[1]             # <<<<<<<<<<<<<<
 * 
 * 			self.weights_ndarray = numpy.array( parameters[2] )
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_parameters, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->bandwidth = __pyx_t_6;

  /* "pomegranate/distributions.pyx":1270
 * 			self.bandwidth = parameters[1]
 * 
 * 			self.weights_ndarray = numpy.array( parameters[2] )             # <<<<<<<<<<<<<<
 * 			self.weights = <double*> self.weights_ndarray.data
 * 
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_parameters, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->weights_ndarray);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->weights_ndarray));
  __pyx_v_self->weights_ndarray = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1271
 * 
 * 			self.weights_ndarray = numpy.array( parameters[2] )
 * 			self.weights = <double*> self.weights_ndarray.data             # <<<<<<<<<<<<<<
 * 
 * 	def __cinit__( self, points, bandwidth=1, weights=None, frozen=False ):
 */
  __pyx_v_self->weights = ((double *)__pyx_v_self->weights_ndarray->data);

  /* "pomegranate/distributions.pyx":1264
 * 		def __get__( self ):
 * 			return [ self.points_ndarray.tolist(), self.bandwidth, self.weights_ndarray.tolist() ]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.points_ndarray = numpy.array( parameters[0] )
 * 			self.points = <double*> self.points_ndarray.data
 */

  /* function exit code */
  __pyx_r = 0;
  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);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pomegranate.distributions.KernelDensity.parameters.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1273
 * 			self.weights = <double*> self.weights_ndarray.data
 * 
 * 	def __cinit__( self, points, bandwidth=1, weights=None, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in points, bandwidth, and appropriate weights. If no weights
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_13KernelDensity_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_13KernelDensity_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_points = 0;
  PyObject *__pyx_v_bandwidth = 0;
  PyObject *__pyx_v_weights = 0;
  PyObject *__pyx_v_frozen = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_points,&__pyx_n_s_bandwidth,&__pyx_n_s_weights,&__pyx_n_s_frozen,0};
    PyObject* values[4] = {0,0,0,0};
    values[1] = ((PyObject *)__pyx_int_1);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_points)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_bandwidth);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1273; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_points = values[0];
    __pyx_v_bandwidth = values[1];
    __pyx_v_weights = values[2];
    __pyx_v_frozen = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1273; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.KernelDensity.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_13KernelDensity___cinit__(((struct __pyx_obj_11pomegranate_13distributions_KernelDensity *)__pyx_v_self), __pyx_v_points, __pyx_v_bandwidth, __pyx_v_weights, __pyx_v_frozen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_13KernelDensity___cinit__(struct __pyx_obj_11pomegranate_13distributions_KernelDensity *__pyx_v_self, PyObject *__pyx_v_points, PyObject *__pyx_v_bandwidth, PyObject *__pyx_v_weights, PyObject *__pyx_v_frozen) {
  PyObject *__pyx_v_n = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  double __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);
  __Pyx_INCREF(__pyx_v_points);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":1280
 * 		"""
 * 
 * 		points = numpy.asarray( points, dtype=numpy.float64 )             # <<<<<<<<<<<<<<
 * 		n = points.shape[0]
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_points);
  __Pyx_GIVEREF(__pyx_v_points);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_points);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_points, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1281
 * 
 * 		points = numpy.asarray( points, dtype=numpy.float64 )
 * 		n = points.shape[0]             # <<<<<<<<<<<<<<
 * 
 * 		if weights is not None:
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_points, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_n = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":1283
 * 		n = points.shape[0]
 * 
 * 		if weights is not None:             # <<<<<<<<<<<<<<
 * 			weights = numpy.array(weights, dtype=numpy.float64) / numpy.sum(weights)
 * 		else:
 */
  __pyx_t_6 = (__pyx_v_weights != Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "pomegranate/distributions.pyx":1284
 * 
 * 		if weights is not None:
 * 			weights = numpy.array(weights, dtype=numpy.float64) / numpy.sum(weights)             # <<<<<<<<<<<<<<
 * 		else:
 * 			weights = numpy.ones( n, dtype=numpy.float64 ) / n
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_weights);
    __Pyx_GIVEREF(__pyx_v_weights);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_weights);
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sum); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_weights); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_weights);
      __Pyx_GIVEREF(__pyx_v_weights);
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_weights);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "pomegranate/distributions.pyx":1283
 * 		n = points.shape[0]
 * 
 * 		if weights is not None:             # <<<<<<<<<<<<<<
 * 			weights = numpy.array(weights, dtype=numpy.float64) / numpy.sum(weights)
 * 		else:
 */
    goto __pyx_L3;
  }

  /* "pomegranate/distributions.pyx":1286
 * 			weights = numpy.array(weights, dtype=numpy.float64) / numpy.sum(weights)
 * 		else:
 * 			weights = numpy.ones( n, dtype=numpy.float64 ) / n             # <<<<<<<<<<<<<<
 * 
 * 		self.n = n
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ones); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_n);
    __Pyx_GIVEREF(__pyx_v_n);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_n);
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float64); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_4);
    __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "pomegranate/distributions.pyx":1288
 * 			weights = numpy.ones( n, dtype=numpy.float64 ) / n
 * 
 * 		self.n = n             # <<<<<<<<<<<<<<
 * 		self.points_ndarray = points
 * 		self.points = <double*> self.points_ndarray.data
 */
  __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_n); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->n = __pyx_t_8;

  /* "pomegranate/distributions.pyx":1289
 * 
 * 		self.n = n
 * 		self.points_ndarray = points             # <<<<<<<<<<<<<<
 * 		self.points = <double*> self.points_ndarray.data
 * 
 */
  if (!(likely(((__pyx_v_points) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_points, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __pyx_v_points;
  __Pyx_INCREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_GOTREF(__pyx_v_self->points_ndarray);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->points_ndarray));
  __pyx_v_self->points_ndarray = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1290
 * 		self.n = n
 * 		self.points_ndarray = points
 * 		self.points = <double*> self.points_ndarray.data             # <<<<<<<<<<<<<<
 * 
 * 		self.weights_ndarray = weights
 */
  __pyx_v_self->points = ((double *)__pyx_v_self->points_ndarray->data);

  /* "pomegranate/distributions.pyx":1292
 * 		self.points = <double*> self.points_ndarray.data
 * 
 * 		self.weights_ndarray = weights             # <<<<<<<<<<<<<<
 * 		self.weights = <double*> self.weights_ndarray.data
 * 
 */
  if (!(likely(((__pyx_v_weights) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_weights, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __pyx_v_weights;
  __Pyx_INCREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_GOTREF(__pyx_v_self->weights_ndarray);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->weights_ndarray));
  __pyx_v_self->weights_ndarray = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1293
 * 
 * 		self.weights_ndarray = weights
 * 		self.weights = <double*> self.weights_ndarray.data             # <<<<<<<<<<<<<<
 * 
 * 		self.bandwidth = bandwidth
 */
  __pyx_v_self->weights = ((double *)__pyx_v_self->weights_ndarray->data);

  /* "pomegranate/distributions.pyx":1295
 * 		self.weights = <double*> self.weights_ndarray.data
 * 
 * 		self.bandwidth = bandwidth             # <<<<<<<<<<<<<<
 * 		self.summaries = []
 * 		self.name = "KernelDensity"
 */
  __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_v_bandwidth); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->bandwidth = __pyx_t_9;

  /* "pomegranate/distributions.pyx":1296
 * 
 * 		self.bandwidth = bandwidth
 * 		self.summaries = []             # <<<<<<<<<<<<<<
 * 		self.name = "KernelDensity"
 * 		self.frozen = frozen
 */
  __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.summaries);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.summaries);
  __pyx_v_self->__pyx_base.summaries = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1297
 * 		self.bandwidth = bandwidth
 * 		self.summaries = []
 * 		self.name = "KernelDensity"             # <<<<<<<<<<<<<<
 * 		self.frozen = frozen
 * 
 */
  __Pyx_INCREF(__pyx_n_s_KernelDensity);
  __Pyx_GIVEREF(__pyx_n_s_KernelDensity);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.name);
  __pyx_v_self->__pyx_base.name = __pyx_n_s_KernelDensity;

  /* "pomegranate/distributions.pyx":1298
 * 		self.summaries = []
 * 		self.name = "KernelDensity"
 * 		self.frozen = frozen             # <<<<<<<<<<<<<<
 * 
 * 	def from_sample( self, points, weights=None, inertia=0.0 ):
 */
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_frozen); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->__pyx_base.frozen = __pyx_t_7;

  /* "pomegranate/distributions.pyx":1273
 * 			self.weights = <double*> self.weights_ndarray.data
 * 
 * 	def __cinit__( self, points, bandwidth=1, weights=None, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in points, bandwidth, and appropriate weights. If no weights
 */

  /* function exit code */
  __pyx_r = 0;
  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);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pomegranate.distributions.KernelDensity.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_n);
  __Pyx_XDECREF(__pyx_v_points);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1300
 * 		self.frozen = frozen
 * 
 * 	def from_sample( self, points, weights=None, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""Replace the points, allowing for inertia if specified."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_13KernelDensity_3from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_13KernelDensity_2from_sample[] = "Replace the points, allowing for inertia if specified.";
static PyObject *__pyx_pw_11pomegranate_13distributions_13KernelDensity_3from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_points = 0;
  PyObject *__pyx_v_weights = 0;
  PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_points,&__pyx_n_s_weights,&__pyx_n_s_inertia,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_points)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1300; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_points = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_inertia = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_sample", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1300; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.KernelDensity.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_13KernelDensity_2from_sample(((struct __pyx_obj_11pomegranate_13distributions_KernelDensity *)__pyx_v_self), __pyx_v_points, __pyx_v_weights, __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_13KernelDensity_2from_sample(struct __pyx_obj_11pomegranate_13distributions_KernelDensity *__pyx_v_self, PyObject *__pyx_v_points, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia) {
  PyObject *__pyx_v_n = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_sample", 0);
  __Pyx_INCREF(__pyx_v_points);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":1304
 * 
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->__pyx_base.frozen == 1) != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":1305
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if self.frozen == True:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		points = numpy.asarray( points, dtype=numpy.float64 )
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":1304
 * 
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":1307
 * 			return
 * 
 * 		points = numpy.asarray( points, dtype=numpy.float64 )             # <<<<<<<<<<<<<<
 * 		n = points.shape[0]
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_points);
  __Pyx_GIVEREF(__pyx_v_points);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_points);
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_float64); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF_SET(__pyx_v_points, __pyx_t_6);
  __pyx_t_6 = 0;

  /* "pomegranate/distributions.pyx":1308
 * 
 * 		points = numpy.asarray( points, dtype=numpy.float64 )
 * 		n = points.shape[0]             # <<<<<<<<<<<<<<
 * 
 * 		# Get the weights, or assign uniform weights
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_points, __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_6, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_n = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1311
 * 
 * 		# Get the weights, or assign uniform weights
 * 		if weights is not None:             # <<<<<<<<<<<<<<
 * 			weights = numpy.array( weights, dtype=numpy.float64 ) / numpy.sum(weights)
 * 		else:
 */
  __pyx_t_1 = (__pyx_v_weights != Py_None);
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "pomegranate/distributions.pyx":1312
 * 		# Get the weights, or assign uniform weights
 * 		if weights is not None:
 * 			weights = numpy.array( weights, dtype=numpy.float64 ) / numpy.sum(weights)             # <<<<<<<<<<<<<<
 * 		else:
 * 			weights = numpy.ones( n, dtype=numpy.float64 ) / n
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_weights);
    __Pyx_GIVEREF(__pyx_v_weights);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_weights);
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sum); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_weights); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(__pyx_v_weights);
      __Pyx_GIVEREF(__pyx_v_weights);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_weights);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyNumber_Divide(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "pomegranate/distributions.pyx":1311
 * 
 * 		# Get the weights, or assign uniform weights
 * 		if weights is not None:             # <<<<<<<<<<<<<<
 * 			weights = numpy.array( weights, dtype=numpy.float64 ) / numpy.sum(weights)
 * 		else:
 */
    goto __pyx_L4;
  }

  /* "pomegranate/distributions.pyx":1314
 * 			weights = numpy.array( weights, dtype=numpy.float64 ) / numpy.sum(weights)
 * 		else:
 * 			weights = numpy.ones( n, dtype=numpy.float64 ) / n             # <<<<<<<<<<<<<<
 * 
 * 		# If no inertia, get rid of the previous points
 */
  /*else*/ {
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_ones); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_n);
    __Pyx_GIVEREF(__pyx_v_n);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_n);
    __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_v_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_5);
    __pyx_t_5 = 0;
  }
  __pyx_L4:;

  /* "pomegranate/distributions.pyx":1317
 * 
 * 		# If no inertia, get rid of the previous points
 * 		if inertia == 0.0:             # <<<<<<<<<<<<<<
 * 			self.points_ndarray = points
 * 			self.weights_ndarray = weights
 */
  __pyx_t_5 = __Pyx_PyFloat_EqObjC(__pyx_v_inertia, __pyx_float_0_0, 0.0, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_7) {

    /* "pomegranate/distributions.pyx":1318
 * 		# If no inertia, get rid of the previous points
 * 		if inertia == 0.0:
 * 			self.points_ndarray = points             # <<<<<<<<<<<<<<
 * 			self.weights_ndarray = weights
 * 			self.n = points.shape[0]
 */
    if (!(likely(((__pyx_v_points) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_points, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __pyx_v_points;
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_v_self->points_ndarray);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->points_ndarray));
    __pyx_v_self->points_ndarray = ((PyArrayObject *)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "pomegranate/distributions.pyx":1319
 * 		if inertia == 0.0:
 * 			self.points_ndarray = points
 * 			self.weights_ndarray = weights             # <<<<<<<<<<<<<<
 * 			self.n = points.shape[0]
 * 
 */
    if (!(likely(((__pyx_v_weights) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_weights, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __pyx_v_weights;
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_v_self->weights_ndarray);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->weights_ndarray));
    __pyx_v_self->weights_ndarray = ((PyArrayObject *)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "pomegranate/distributions.pyx":1320
 * 			self.points_ndarray = points
 * 			self.weights_ndarray = weights
 * 			self.n = points.shape[0]             # <<<<<<<<<<<<<<
 * 
 * 		# Otherwise adjust weights appropriately
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_points, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_self->n = __pyx_t_8;

    /* "pomegranate/distributions.pyx":1317
 * 
 * 		# If no inertia, get rid of the previous points
 * 		if inertia == 0.0:             # <<<<<<<<<<<<<<
 * 			self.points_ndarray = points
 * 			self.weights_ndarray = weights
 */
    goto __pyx_L5;
  }

  /* "pomegranate/distributions.pyx":1324
 * 		# Otherwise adjust weights appropriately
 * 		else:
 * 			self.points_ndarray = numpy.concatenate( ( self.points_ndarray, points ) )             # <<<<<<<<<<<<<<
 * 			self.weights_ndarray = numpy.concatenate( ( self.weights_ndarray*inertia, weights*(1-inertia) ) )
 * 			self.n = points.shape[0]
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_v_self->points_ndarray));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->points_ndarray));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self->points_ndarray));
    __Pyx_INCREF(__pyx_v_points);
    __Pyx_GIVEREF(__pyx_v_points);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_points);
    __pyx_t_2 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_2) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 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 = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_v_self->points_ndarray);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->points_ndarray));
    __pyx_v_self->points_ndarray = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":1325
 * 		else:
 * 			self.points_ndarray = numpy.concatenate( ( self.points_ndarray, points ) )
 * 			self.weights_ndarray = numpy.concatenate( ( self.weights_ndarray*inertia, weights*(1-inertia) ) )             # <<<<<<<<<<<<<<
 * 			self.n = points.shape[0]
 * 
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_Multiply(((PyObject *)__pyx_v_self->weights_ndarray), __pyx_v_inertia); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_inertia, 1, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyNumber_Multiply(__pyx_v_weights, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __pyx_t_6 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_2) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__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 = 1325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_v_self->weights_ndarray);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->weights_ndarray));
    __pyx_v_self->weights_ndarray = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":1326
 * 			self.points_ndarray = numpy.concatenate( ( self.points_ndarray, points ) )
 * 			self.weights_ndarray = numpy.concatenate( ( self.weights_ndarray*inertia, weights*(1-inertia) ) )
 * 			self.n = points.shape[0]             # <<<<<<<<<<<<<<
 * 
 * 		self.points = <double*> self.points_ndarray.data
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_points, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1326; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_self->n = __pyx_t_8;
  }
  __pyx_L5:;

  /* "pomegranate/distributions.pyx":1328
 * 			self.n = points.shape[0]
 * 
 * 		self.points = <double*> self.points_ndarray.data             # <<<<<<<<<<<<<<
 * 		self.weights = <double*> self.weights_ndarray.data
 * 
 */
  __pyx_v_self->points = ((double *)__pyx_v_self->points_ndarray->data);

  /* "pomegranate/distributions.pyx":1329
 * 
 * 		self.points = <double*> self.points_ndarray.data
 * 		self.weights = <double*> self.weights_ndarray.data             # <<<<<<<<<<<<<<
 * 
 * cdef class GaussianKernelDensity( KernelDensity ):
 */
  __pyx_v_self->weights = ((double *)__pyx_v_self->weights_ndarray->data);

  /* "pomegranate/distributions.pyx":1300
 * 		self.frozen = frozen
 * 
 * 	def from_sample( self, points, weights=None, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""Replace the points, allowing for inertia if specified."""
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pomegranate.distributions.KernelDensity.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_n);
  __Pyx_XDECREF(__pyx_v_points);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1338
 * 	"""
 * 
 * 	def __cinit__( self, points, bandwidth=1, weights=None, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in points, bandwidth, and appropriate weights. If no weights
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_21GaussianKernelDensity_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_21GaussianKernelDensity_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_points = 0;
  CYTHON_UNUSED PyObject *__pyx_v_bandwidth = 0;
  CYTHON_UNUSED PyObject *__pyx_v_weights = 0;
  CYTHON_UNUSED PyObject *__pyx_v_frozen = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_points,&__pyx_n_s_bandwidth,&__pyx_n_s_weights,&__pyx_n_s_frozen,0};
    PyObject* values[4] = {0,0,0,0};
    values[1] = ((PyObject *)__pyx_int_1);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_points)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_bandwidth);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1338; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_points = values[0];
    __pyx_v_bandwidth = values[1];
    __pyx_v_weights = values[2];
    __pyx_v_frozen = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1338; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.GaussianKernelDensity.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21GaussianKernelDensity___cinit__(((struct __pyx_obj_11pomegranate_13distributions_GaussianKernelDensity *)__pyx_v_self), __pyx_v_points, __pyx_v_bandwidth, __pyx_v_weights, __pyx_v_frozen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_21GaussianKernelDensity___cinit__(struct __pyx_obj_11pomegranate_13distributions_GaussianKernelDensity *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_points, CYTHON_UNUSED PyObject *__pyx_v_bandwidth, CYTHON_UNUSED PyObject *__pyx_v_weights, CYTHON_UNUSED PyObject *__pyx_v_frozen) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "pomegranate/distributions.pyx":1345
 * 		"""
 * 
 * 		self.name = "GaussianKernelDensity"             # <<<<<<<<<<<<<<
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:
 */
  __Pyx_INCREF(__pyx_n_s_GaussianKernelDensity);
  __Pyx_GIVEREF(__pyx_n_s_GaussianKernelDensity);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.__pyx_base.name);
  __pyx_v_self->__pyx_base.__pyx_base.name = __pyx_n_s_GaussianKernelDensity;

  /* "pomegranate/distributions.pyx":1338
 * 	"""
 * 
 * 	def __cinit__( self, points, bandwidth=1, weights=None, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in points, bandwidth, and appropriate weights. If no weights
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1347
 * 		self.name = "GaussianKernelDensity"
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

static double __pyx_f_11pomegranate_13distributions_21GaussianKernelDensity__log_probability(struct __pyx_obj_11pomegranate_13distributions_GaussianKernelDensity *__pyx_v_self, double __pyx_v_symbol) {
  double __pyx_v_mu;
  double __pyx_v_w;
  double __pyx_v_scalar;
  int __pyx_v_i;
  int __pyx_v_n;
  double __pyx_v_prob;
  double __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;

  /* "pomegranate/distributions.pyx":1351
 * 
 * 		cdef double mu, w
 * 		cdef double scalar = 1.0 / SQRT_2_PI             # <<<<<<<<<<<<<<
 * 		cdef int i, n = self.n
 * 		cdef double prob = 0.0
 */
  __pyx_v_scalar = (1.0 / 2.50662827463);

  /* "pomegranate/distributions.pyx":1352
 * 		cdef double mu, w
 * 		cdef double scalar = 1.0 / SQRT_2_PI
 * 		cdef int i, n = self.n             # <<<<<<<<<<<<<<
 * 		cdef double prob = 0.0
 * 
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.n;
  __pyx_v_n = __pyx_t_1;

  /* "pomegranate/distributions.pyx":1353
 * 		cdef double scalar = 1.0 / SQRT_2_PI
 * 		cdef int i, n = self.n
 * 		cdef double prob = 0.0             # <<<<<<<<<<<<<<
 * 
 * 		for i in range( n ):
 */
  __pyx_v_prob = 0.0;

  /* "pomegranate/distributions.pyx":1355
 * 		cdef double prob = 0.0
 * 
 * 		for i in range( n ):             # <<<<<<<<<<<<<<
 * 			mu = self.points[i]
 * 			w = self.weights[i]
 */
  __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;

    /* "pomegranate/distributions.pyx":1356
 * 
 * 		for i in range( n ):
 * 			mu = self.points[i]             # <<<<<<<<<<<<<<
 * 			w = self.weights[i]
 * 
 */
    __pyx_v_mu = (__pyx_v_self->__pyx_base.points[__pyx_v_i]);

    /* "pomegranate/distributions.pyx":1357
 * 		for i in range( n ):
 * 			mu = self.points[i]
 * 			w = self.weights[i]             # <<<<<<<<<<<<<<
 * 
 * 			prob += w * scalar * cexp( -0.5 * (( mu-symbol ) / self.bandwidth) ** 2 )
 */
    __pyx_v_w = (__pyx_v_self->__pyx_base.weights[__pyx_v_i]);

    /* "pomegranate/distributions.pyx":1359
 * 			w = self.weights[i]
 * 
 * 			prob += w * scalar * cexp( -0.5 * (( mu-symbol ) / self.bandwidth) ** 2 )             # <<<<<<<<<<<<<<
 * 
 * 		return _log( prob )
 */
    __pyx_v_prob = (__pyx_v_prob + ((__pyx_v_w * __pyx_v_scalar) * exp((-0.5 * pow(((__pyx_v_mu - __pyx_v_symbol) / __pyx_v_self->__pyx_base.bandwidth), 2.0)))));
  }

  /* "pomegranate/distributions.pyx":1361
 * 			prob += w * scalar * cexp( -0.5 * (( mu-symbol ) / self.bandwidth) ** 2 )
 * 
 * 		return _log( prob )             # <<<<<<<<<<<<<<
 * 
 * 	def sample( self ):
 */
  __pyx_r = __pyx_f_11pomegranate_5utils__log(__pyx_v_prob);
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1347
 * 		self.name = "GaussianKernelDensity"
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1363
 * 		return _log( prob )
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Generate a random sample from this distribution. This is done by first
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_21GaussianKernelDensity_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_21GaussianKernelDensity_2sample[] = "\n\t\tGenerate a random sample from this distribution. This is done by first\n\t\tselecting a random point, weighted by weights if the points are weighted\n\t\tor uniformly if not, and then randomly sampling from that point's PDF.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_21GaussianKernelDensity_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21GaussianKernelDensity_2sample(((struct __pyx_obj_11pomegranate_13distributions_GaussianKernelDensity *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_21GaussianKernelDensity_2sample(struct __pyx_obj_11pomegranate_13distributions_GaussianKernelDensity *__pyx_v_self) {
  PyObject *__pyx_v_mu = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);

  /* "pomegranate/distributions.pyx":1370
 * 		"""
 * 
 * 		mu = numpy.random.choice( self.parameters[0], p=self.parameters[2] )             # <<<<<<<<<<<<<<
 * 		return random.gauss( mu, self.parameters[1] )
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_choice); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_p, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_mu = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1371
 * 
 * 		mu = numpy.random.choice( self.parameters[0], p=self.parameters[2] )
 * 		return random.gauss( mu, self.parameters[1] )             # <<<<<<<<<<<<<<
 * 
 * cdef class UniformKernelDensity( KernelDensity ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_gauss); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (__pyx_t_3) {
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
  }
  __Pyx_INCREF(__pyx_v_mu);
  __Pyx_GIVEREF(__pyx_v_mu);
  PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_mu);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1363
 * 		return _log( prob )
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Generate a random sample from this distribution. This is done by first
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pomegranate.distributions.GaussianKernelDensity.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_mu);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1380
 * 	"""
 * 
 * 	def __cinit__( self, points, bandwidth=1, weights=None, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in points, bandwidth, and appropriate weights. If no weights
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_20UniformKernelDensity_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_20UniformKernelDensity_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_points = 0;
  CYTHON_UNUSED PyObject *__pyx_v_bandwidth = 0;
  CYTHON_UNUSED PyObject *__pyx_v_weights = 0;
  CYTHON_UNUSED PyObject *__pyx_v_frozen = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_points,&__pyx_n_s_bandwidth,&__pyx_n_s_weights,&__pyx_n_s_frozen,0};
    PyObject* values[4] = {0,0,0,0};
    values[1] = ((PyObject *)__pyx_int_1);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_points)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_bandwidth);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1380; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_points = values[0];
    __pyx_v_bandwidth = values[1];
    __pyx_v_weights = values[2];
    __pyx_v_frozen = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1380; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.UniformKernelDensity.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20UniformKernelDensity___cinit__(((struct __pyx_obj_11pomegranate_13distributions_UniformKernelDensity *)__pyx_v_self), __pyx_v_points, __pyx_v_bandwidth, __pyx_v_weights, __pyx_v_frozen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_20UniformKernelDensity___cinit__(struct __pyx_obj_11pomegranate_13distributions_UniformKernelDensity *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_points, CYTHON_UNUSED PyObject *__pyx_v_bandwidth, CYTHON_UNUSED PyObject *__pyx_v_weights, CYTHON_UNUSED PyObject *__pyx_v_frozen) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "pomegranate/distributions.pyx":1387
 * 		"""
 * 
 * 		self.name = "UniformKernelDensity"             # <<<<<<<<<<<<<<
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:
 */
  __Pyx_INCREF(__pyx_n_s_UniformKernelDensity);
  __Pyx_GIVEREF(__pyx_n_s_UniformKernelDensity);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.__pyx_base.name);
  __pyx_v_self->__pyx_base.__pyx_base.name = __pyx_n_s_UniformKernelDensity;

  /* "pomegranate/distributions.pyx":1380
 * 	"""
 * 
 * 	def __cinit__( self, points, bandwidth=1, weights=None, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in points, bandwidth, and appropriate weights. If no weights
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1389
 * 		self.name = "UniformKernelDensity"
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

static double __pyx_f_11pomegranate_13distributions_20UniformKernelDensity__log_probability(struct __pyx_obj_11pomegranate_13distributions_UniformKernelDensity *__pyx_v_self, double __pyx_v_symbol) {
  double __pyx_v_bandwidth;
  double __pyx_v_mu;
  double __pyx_v_w;
  int __pyx_v_i;
  int __pyx_v_n;
  double __pyx_v_prob;
  double __pyx_r;
  double __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;

  /* "pomegranate/distributions.pyx":1392
 * 		"""Cython optimized function for log probability calculation."""
 * 
 * 		cdef double bandwidth = self.bandwidth             # <<<<<<<<<<<<<<
 * 		cdef double mu, w
 * 
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.bandwidth;
  __pyx_v_bandwidth = __pyx_t_1;

  /* "pomegranate/distributions.pyx":1395
 * 		cdef double mu, w
 * 
 * 		cdef int i, n = self.n             # <<<<<<<<<<<<<<
 * 		cdef double prob = 0.0
 * 
 */
  __pyx_t_2 = __pyx_v_self->__pyx_base.n;
  __pyx_v_n = __pyx_t_2;

  /* "pomegranate/distributions.pyx":1396
 * 
 * 		cdef int i, n = self.n
 * 		cdef double prob = 0.0             # <<<<<<<<<<<<<<
 * 
 * 		for i in range( n ):
 */
  __pyx_v_prob = 0.0;

  /* "pomegranate/distributions.pyx":1398
 * 		cdef double prob = 0.0
 * 
 * 		for i in range( n ):             # <<<<<<<<<<<<<<
 * 			# Go through each point sequentially
 * 			mu = self.points[i]
 */
  __pyx_t_2 = __pyx_v_n;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "pomegranate/distributions.pyx":1400
 * 		for i in range( n ):
 * 			# Go through each point sequentially
 * 			mu = self.points[i]             # <<<<<<<<<<<<<<
 * 			w = self.weights[i]
 * 
 */
    __pyx_v_mu = (__pyx_v_self->__pyx_base.points[__pyx_v_i]);

    /* "pomegranate/distributions.pyx":1401
 * 			# Go through each point sequentially
 * 			mu = self.points[i]
 * 			w = self.weights[i]             # <<<<<<<<<<<<<<
 * 
 * 			# The good thing about uniform distributions if that
 */
    __pyx_v_w = (__pyx_v_self->__pyx_base.weights[__pyx_v_i]);

    /* "pomegranate/distributions.pyx":1406
 * 			# you just need to check to make sure the point is within
 * 			# a bandwidth.
 * 			if fabs( mu - symbol ) <= bandwidth:             # <<<<<<<<<<<<<<
 * 				prob += w
 * 
 */
    __pyx_t_4 = ((fabs((__pyx_v_mu - __pyx_v_symbol)) <= __pyx_v_bandwidth) != 0);
    if (__pyx_t_4) {

      /* "pomegranate/distributions.pyx":1407
 * 			# a bandwidth.
 * 			if fabs( mu - symbol ) <= bandwidth:
 * 				prob += w             # <<<<<<<<<<<<<<
 * 
 * 		# Return the log of the sum of probabilities
 */
      __pyx_v_prob = (__pyx_v_prob + __pyx_v_w);

      /* "pomegranate/distributions.pyx":1406
 * 			# you just need to check to make sure the point is within
 * 			# a bandwidth.
 * 			if fabs( mu - symbol ) <= bandwidth:             # <<<<<<<<<<<<<<
 * 				prob += w
 * 
 */
    }
  }

  /* "pomegranate/distributions.pyx":1410
 * 
 * 		# Return the log of the sum of probabilities
 * 		return _log( prob )             # <<<<<<<<<<<<<<
 * 
 * 	def sample( self ):
 */
  __pyx_r = __pyx_f_11pomegranate_5utils__log(__pyx_v_prob);
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1389
 * 		self.name = "UniformKernelDensity"
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1412
 * 		return _log( prob )
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Generate a random sample from this distribution. This is done by first
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_20UniformKernelDensity_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_20UniformKernelDensity_2sample[] = "\n\t\tGenerate a random sample from this distribution. This is done by first\n\t\tselecting a random point, weighted by weights if the points are weighted\n\t\tor uniformly if not, and then randomly sampling from that point's PDF.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_20UniformKernelDensity_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_20UniformKernelDensity_2sample(((struct __pyx_obj_11pomegranate_13distributions_UniformKernelDensity *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_20UniformKernelDensity_2sample(struct __pyx_obj_11pomegranate_13distributions_UniformKernelDensity *__pyx_v_self) {
  PyObject *__pyx_v_mu = NULL;
  PyObject *__pyx_v_bandwidth = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);

  /* "pomegranate/distributions.pyx":1419
 * 		"""
 * 
 * 		mu = numpy.random.choice( self.parameters[0], p=self.parameters[2] )             # <<<<<<<<<<<<<<
 * 		bandwidth = self.parameters[1]
 * 		return random.uniform( mu-bandwidth, mu+bandwidth )
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_choice); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_p, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_mu = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1420
 * 
 * 		mu = numpy.random.choice( self.parameters[0], p=self.parameters[2] )
 * 		bandwidth = self.parameters[1]             # <<<<<<<<<<<<<<
 * 		return random.uniform( mu-bandwidth, mu+bandwidth )
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_5, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_bandwidth = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":1421
 * 		mu = numpy.random.choice( self.parameters[0], p=self.parameters[2] )
 * 		bandwidth = self.parameters[1]
 * 		return random.uniform( mu-bandwidth, mu+bandwidth )             # <<<<<<<<<<<<<<
 * 
 * cdef class TriangleKernelDensity( KernelDensity ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_uniform); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Subtract(__pyx_v_mu, __pyx_v_bandwidth); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyNumber_Add(__pyx_v_mu, __pyx_v_bandwidth); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_1);
  __pyx_t_5 = 0;
  __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1412
 * 		return _log( prob )
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Generate a random sample from this distribution. This is done by first
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.UniformKernelDensity.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_mu);
  __Pyx_XDECREF(__pyx_v_bandwidth);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1430
 * 	"""
 * 
 * 	def __cinit__( self, points, bandwidth=1, weights=None, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in points, bandwidth, and appropriate weights. If no weights
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_21TriangleKernelDensity_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_21TriangleKernelDensity_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_points = 0;
  CYTHON_UNUSED PyObject *__pyx_v_bandwidth = 0;
  CYTHON_UNUSED PyObject *__pyx_v_weights = 0;
  CYTHON_UNUSED PyObject *__pyx_v_frozen = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_points,&__pyx_n_s_bandwidth,&__pyx_n_s_weights,&__pyx_n_s_frozen,0};
    PyObject* values[4] = {0,0,0,0};
    values[1] = ((PyObject *)__pyx_int_1);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_points)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_bandwidth);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1430; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_points = values[0];
    __pyx_v_bandwidth = values[1];
    __pyx_v_weights = values[2];
    __pyx_v_frozen = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1430; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.TriangleKernelDensity.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21TriangleKernelDensity___cinit__(((struct __pyx_obj_11pomegranate_13distributions_TriangleKernelDensity *)__pyx_v_self), __pyx_v_points, __pyx_v_bandwidth, __pyx_v_weights, __pyx_v_frozen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_21TriangleKernelDensity___cinit__(struct __pyx_obj_11pomegranate_13distributions_TriangleKernelDensity *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_points, CYTHON_UNUSED PyObject *__pyx_v_bandwidth, CYTHON_UNUSED PyObject *__pyx_v_weights, CYTHON_UNUSED PyObject *__pyx_v_frozen) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "pomegranate/distributions.pyx":1437
 * 		"""
 * 
 * 		self.name = "TriangleKernelDensity"             # <<<<<<<<<<<<<<
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:
 */
  __Pyx_INCREF(__pyx_n_s_TriangleKernelDensity);
  __Pyx_GIVEREF(__pyx_n_s_TriangleKernelDensity);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.__pyx_base.name);
  __pyx_v_self->__pyx_base.__pyx_base.name = __pyx_n_s_TriangleKernelDensity;

  /* "pomegranate/distributions.pyx":1430
 * 	"""
 * 
 * 	def __cinit__( self, points, bandwidth=1, weights=None, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in points, bandwidth, and appropriate weights. If no weights
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1439
 * 		self.name = "TriangleKernelDensity"
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

static double __pyx_f_11pomegranate_13distributions_21TriangleKernelDensity__log_probability(struct __pyx_obj_11pomegranate_13distributions_TriangleKernelDensity *__pyx_v_self, double __pyx_v_symbol) {
  double __pyx_v_bandwidth;
  double __pyx_v_mu;
  double __pyx_v_w;
  int __pyx_v_i;
  int __pyx_v_n;
  double __pyx_v_prob;
  double __pyx_v_hinge;
  double __pyx_r;
  double __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;

  /* "pomegranate/distributions.pyx":1442
 * 		"""Cython optimized function for log probability calculation."""
 * 
 * 		cdef double bandwidth = self.bandwidth             # <<<<<<<<<<<<<<
 * 		cdef double mu, w
 * 
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.bandwidth;
  __pyx_v_bandwidth = __pyx_t_1;

  /* "pomegranate/distributions.pyx":1445
 * 		cdef double mu, w
 * 
 * 		cdef int i, n = self.n             # <<<<<<<<<<<<<<
 * 		cdef double prob = 0.0, hinge
 * 
 */
  __pyx_t_2 = __pyx_v_self->__pyx_base.n;
  __pyx_v_n = __pyx_t_2;

  /* "pomegranate/distributions.pyx":1446
 * 
 * 		cdef int i, n = self.n
 * 		cdef double prob = 0.0, hinge             # <<<<<<<<<<<<<<
 * 
 * 		for i in range( n ):
 */
  __pyx_v_prob = 0.0;

  /* "pomegranate/distributions.pyx":1448
 * 		cdef double prob = 0.0, hinge
 * 
 * 		for i in range( n ):             # <<<<<<<<<<<<<<
 * 			# Go through each point sequentially
 * 			mu = self.points[i]
 */
  __pyx_t_2 = __pyx_v_n;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "pomegranate/distributions.pyx":1450
 * 		for i in range( n ):
 * 			# Go through each point sequentially
 * 			mu = self.points[i]             # <<<<<<<<<<<<<<
 * 			w = self.weights[i]
 * 
 */
    __pyx_v_mu = (__pyx_v_self->__pyx_base.points[__pyx_v_i]);

    /* "pomegranate/distributions.pyx":1451
 * 			# Go through each point sequentially
 * 			mu = self.points[i]
 * 			w = self.weights[i]             # <<<<<<<<<<<<<<
 * 
 * 			# Calculate the probability for each point
 */
    __pyx_v_w = (__pyx_v_self->__pyx_base.weights[__pyx_v_i]);

    /* "pomegranate/distributions.pyx":1454
 * 
 * 			# Calculate the probability for each point
 * 			hinge = bandwidth - fabs( mu - symbol )             # <<<<<<<<<<<<<<
 * 			if hinge > 0:
 * 				prob += hinge * w
 */
    __pyx_v_hinge = (__pyx_v_bandwidth - fabs((__pyx_v_mu - __pyx_v_symbol)));

    /* "pomegranate/distributions.pyx":1455
 * 			# Calculate the probability for each point
 * 			hinge = bandwidth - fabs( mu - symbol )
 * 			if hinge > 0:             # <<<<<<<<<<<<<<
 * 				prob += hinge * w
 * 
 */
    __pyx_t_4 = ((__pyx_v_hinge > 0.0) != 0);
    if (__pyx_t_4) {

      /* "pomegranate/distributions.pyx":1456
 * 			hinge = bandwidth - fabs( mu - symbol )
 * 			if hinge > 0:
 * 				prob += hinge * w             # <<<<<<<<<<<<<<
 * 
 * 		# Return the log of the sum of probabilities
 */
      __pyx_v_prob = (__pyx_v_prob + (__pyx_v_hinge * __pyx_v_w));

      /* "pomegranate/distributions.pyx":1455
 * 			# Calculate the probability for each point
 * 			hinge = bandwidth - fabs( mu - symbol )
 * 			if hinge > 0:             # <<<<<<<<<<<<<<
 * 				prob += hinge * w
 * 
 */
    }
  }

  /* "pomegranate/distributions.pyx":1459
 * 
 * 		# Return the log of the sum of probabilities
 * 		return _log( prob )             # <<<<<<<<<<<<<<
 * 
 * 	def sample( self ):
 */
  __pyx_r = __pyx_f_11pomegranate_5utils__log(__pyx_v_prob);
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1439
 * 		self.name = "TriangleKernelDensity"
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1461
 * 		return _log( prob )
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Generate a random sample from this distribution. This is done by first
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_21TriangleKernelDensity_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_21TriangleKernelDensity_2sample[] = "\n\t\tGenerate a random sample from this distribution. This is done by first\n\t\tselecting a random point, weighted by weights if the points are weighted\n\t\tor uniformly if not, and then randomly sampling from that point's PDF.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_21TriangleKernelDensity_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21TriangleKernelDensity_2sample(((struct __pyx_obj_11pomegranate_13distributions_TriangleKernelDensity *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_21TriangleKernelDensity_2sample(struct __pyx_obj_11pomegranate_13distributions_TriangleKernelDensity *__pyx_v_self) {
  PyObject *__pyx_v_mu = NULL;
  PyObject *__pyx_v_bandwidth = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);

  /* "pomegranate/distributions.pyx":1468
 * 		"""
 * 
 * 		mu = numpy.random.choice( self.parameters[0], p=self.parameters[2] )             # <<<<<<<<<<<<<<
 * 		bandwidth = self.parameters[1]
 * 		return random.triangular( mu-bandwidth, mu+bandwidth, mu )
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_choice); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_p, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_mu = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1469
 * 
 * 		mu = numpy.random.choice( self.parameters[0], p=self.parameters[2] )
 * 		bandwidth = self.parameters[1]             # <<<<<<<<<<<<<<
 * 		return random.triangular( mu-bandwidth, mu+bandwidth, mu )
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_5, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_bandwidth = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":1470
 * 		mu = numpy.random.choice( self.parameters[0], p=self.parameters[2] )
 * 		bandwidth = self.parameters[1]
 * 		return random.triangular( mu-bandwidth, mu+bandwidth, mu )             # <<<<<<<<<<<<<<
 * 
 * cdef class MixtureDistribution( Distribution ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_triangular); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Subtract(__pyx_v_mu, __pyx_v_bandwidth); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyNumber_Add(__pyx_v_mu, __pyx_v_bandwidth); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_4) {
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_mu);
  __Pyx_GIVEREF(__pyx_v_mu);
  PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_mu);
  __pyx_t_5 = 0;
  __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1461
 * 		return _log( prob )
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Generate a random sample from this distribution. This is done by first
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.TriangleKernelDensity.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_mu);
  __Pyx_XDECREF(__pyx_v_bandwidth);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1480
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [ self.distributions.tolist(), self.weights.tolist() ]
 * 		def __set__( self, parameters ):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_10parameters_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_10parameters_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_19MixtureDistribution_10parameters___get__(((struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_19MixtureDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pomegranate/distributions.pyx":1481
 * 	property parameters:
 * 		def __get__( self ):
 * 			return [ self.distributions.tolist(), self.weights.tolist() ]             # <<<<<<<<<<<<<<
 * 		def __set__( self, parameters ):
 * 			self.distributions = numpy.asarray( parameters[0], dtype=numpy.object_ )
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->distributions), __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->weights), __pyx_n_s_tolist); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1480
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [ self.distributions.tolist(), self.weights.tolist() ]
 * 		def __set__( self, parameters ):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pomegranate.distributions.MixtureDistribution.parameters.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1482
 * 		def __get__( self ):
 * 			return [ self.distributions.tolist(), self.weights.tolist() ]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.distributions = numpy.asarray( parameters[0], dtype=numpy.object_ )
 * 			self.weights = numpy.array( parameters[1] )
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_19MixtureDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_19MixtureDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_19MixtureDistribution_10parameters_2__set__(((struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_parameters));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_19MixtureDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "pomegranate/distributions.pyx":1483
 * 			return [ self.distributions.tolist(), self.weights.tolist() ]
 * 		def __set__( self, parameters ):
 * 			self.distributions = numpy.asarray( parameters[0], dtype=numpy.object_ )             # <<<<<<<<<<<<<<
 * 			self.weights = numpy.array( parameters[1] )
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_parameters, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_object); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_GOTREF(__pyx_v_self->distributions);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->distributions));
  __pyx_v_self->distributions = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1484
 * 		def __set__( self, parameters ):
 * 			self.distributions = numpy.asarray( parameters[0], dtype=numpy.object_ )
 * 			self.weights = numpy.array( parameters[1] )             # <<<<<<<<<<<<<<
 * 
 * 	def __cinit__( self, distributions, weights=None, frozen=False ):
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_parameters, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1484; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_GOTREF(__pyx_v_self->weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->weights));
  __pyx_v_self->weights = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1482
 * 		def __get__( self ):
 * 			return [ self.distributions.tolist(), self.weights.tolist() ]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.distributions = numpy.asarray( parameters[0], dtype=numpy.object_ )
 * 			self.weights = numpy.array( parameters[1] )
 */

  /* function exit code */
  __pyx_r = 0;
  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);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pomegranate.distributions.MixtureDistribution.parameters.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1486
 * 			self.weights = numpy.array( parameters[1] )
 * 
 * 	def __cinit__( self, distributions, weights=None, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in the distributions and appropriate weights. If no weights
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_19MixtureDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_19MixtureDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_distributions = 0;
  PyObject *__pyx_v_weights = 0;
  PyObject *__pyx_v_frozen = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_distributions,&__pyx_n_s_weights,&__pyx_n_s_frozen,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_distributions)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_distributions = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_frozen = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.MixtureDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_19MixtureDistribution___cinit__(((struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *)__pyx_v_self), __pyx_v_distributions, __pyx_v_weights, __pyx_v_frozen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_19MixtureDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self, PyObject *__pyx_v_distributions, PyObject *__pyx_v_weights, PyObject *__pyx_v_frozen) {
  PyObject *__pyx_v_n = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);
  __Pyx_INCREF(__pyx_v_distributions);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":1493
 * 		"""
 * 
 * 		distributions = numpy.asarray( distributions, dtype=numpy.object_ )             # <<<<<<<<<<<<<<
 * 		n = distributions.shape[0]
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_distributions);
  __Pyx_GIVEREF(__pyx_v_distributions);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_distributions);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_object); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_distributions, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1494
 * 
 * 		distributions = numpy.asarray( distributions, dtype=numpy.object_ )
 * 		n = distributions.shape[0]             # <<<<<<<<<<<<<<
 * 
 * 		if weights:
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_distributions, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1494; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_n = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":1496
 * 		n = distributions.shape[0]
 * 
 * 		if weights:             # <<<<<<<<<<<<<<
 * 			weights = numpy.array( weights, dtype=numpy.float64 ) / numpy.sum( weights )
 * 		else:
 */
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_weights); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_6) {

    /* "pomegranate/distributions.pyx":1497
 * 
 * 		if weights:
 * 			weights = numpy.array( weights, dtype=numpy.float64 ) / numpy.sum( weights )             # <<<<<<<<<<<<<<
 * 		else:
 * 			weights = numpy.ones(n, dtype=numpy.float64 ) / n
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_weights);
    __Pyx_GIVEREF(__pyx_v_weights);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_weights);
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sum); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_weights); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_weights);
      __Pyx_GIVEREF(__pyx_v_weights);
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_weights);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "pomegranate/distributions.pyx":1496
 * 		n = distributions.shape[0]
 * 
 * 		if weights:             # <<<<<<<<<<<<<<
 * 			weights = numpy.array( weights, dtype=numpy.float64 ) / numpy.sum( weights )
 * 		else:
 */
    goto __pyx_L3;
  }

  /* "pomegranate/distributions.pyx":1499
 * 			weights = numpy.array( weights, dtype=numpy.float64 ) / numpy.sum( weights )
 * 		else:
 * 			weights = numpy.ones(n, dtype=numpy.float64 ) / n             # <<<<<<<<<<<<<<
 * 
 * 		self.n = n
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ones); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_n);
    __Pyx_GIVEREF(__pyx_v_n);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_n);
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float64); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_4);
    __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "pomegranate/distributions.pyx":1501
 * 			weights = numpy.ones(n, dtype=numpy.float64 ) / n
 * 
 * 		self.n = n             # <<<<<<<<<<<<<<
 * 		self.distributions = distributions
 * 		self.weights = weights
 */
  __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_n); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->n = __pyx_t_7;

  /* "pomegranate/distributions.pyx":1502
 * 
 * 		self.n = n
 * 		self.distributions = distributions             # <<<<<<<<<<<<<<
 * 		self.weights = weights
 * 		self.weights_p = <double*> (<numpy.ndarray> weights).data
 */
  if (!(likely(((__pyx_v_distributions) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_distributions, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __pyx_v_distributions;
  __Pyx_INCREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_GOTREF(__pyx_v_self->distributions);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->distributions));
  __pyx_v_self->distributions = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1503
 * 		self.n = n
 * 		self.distributions = distributions
 * 		self.weights = weights             # <<<<<<<<<<<<<<
 * 		self.weights_p = <double*> (<numpy.ndarray> weights).data
 * 		self.distributions = distributions
 */
  if (!(likely(((__pyx_v_weights) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_weights, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __pyx_v_weights;
  __Pyx_INCREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_GOTREF(__pyx_v_self->weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->weights));
  __pyx_v_self->weights = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1504
 * 		self.distributions = distributions
 * 		self.weights = weights
 * 		self.weights_p = <double*> (<numpy.ndarray> weights).data             # <<<<<<<<<<<<<<
 * 		self.distributions = distributions
 * 		self.name = "MixtureDistribution"
 */
  __pyx_v_self->weights_p = ((double *)((PyArrayObject *)__pyx_v_weights)->data);

  /* "pomegranate/distributions.pyx":1505
 * 		self.weights = weights
 * 		self.weights_p = <double*> (<numpy.ndarray> weights).data
 * 		self.distributions = distributions             # <<<<<<<<<<<<<<
 * 		self.name = "MixtureDistribution"
 * 		self.frozen = frozen
 */
  if (!(likely(((__pyx_v_distributions) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_distributions, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __pyx_v_distributions;
  __Pyx_INCREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_GOTREF(__pyx_v_self->distributions);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->distributions));
  __pyx_v_self->distributions = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1506
 * 		self.weights_p = <double*> (<numpy.ndarray> weights).data
 * 		self.distributions = distributions
 * 		self.name = "MixtureDistribution"             # <<<<<<<<<<<<<<
 * 		self.frozen = frozen
 * 
 */
  __Pyx_INCREF(__pyx_n_s_MixtureDistribution);
  __Pyx_GIVEREF(__pyx_n_s_MixtureDistribution);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.name);
  __pyx_v_self->__pyx_base.name = __pyx_n_s_MixtureDistribution;

  /* "pomegranate/distributions.pyx":1507
 * 		self.distributions = distributions
 * 		self.name = "MixtureDistribution"
 * 		self.frozen = frozen             # <<<<<<<<<<<<<<
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:
 */
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_frozen); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->__pyx_base.frozen = __pyx_t_6;

  /* "pomegranate/distributions.pyx":1486
 * 			self.weights = numpy.array( parameters[1] )
 * 
 * 	def __cinit__( self, distributions, weights=None, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in the distributions and appropriate weights. If no weights
 */

  /* function exit code */
  __pyx_r = 0;
  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);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pomegranate.distributions.MixtureDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_n);
  __Pyx_XDECREF(__pyx_v_distributions);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1509
 * 		self.frozen = frozen
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

static double __pyx_f_11pomegranate_13distributions_19MixtureDistribution__log_probability(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self, double __pyx_v_symbol) {
  int __pyx_v_i;
  int __pyx_v_n;
  double __pyx_v_w;
  double __pyx_v_prob;
  PyObject *__pyx_v_d = NULL;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  double __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_log_probability", 0);
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif

  /* "pomegranate/distributions.pyx":1510
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:
 * 		"""Cython optimized function for log probability calculation."""             # <<<<<<<<<<<<<<
 * 
 * 		cdef int i, n = self.n
 */
  /*try:*/ {

    /* "pomegranate/distributions.pyx":1512
 * 		"""Cython optimized function for log probability calculation."""
 * 
 * 		cdef int i, n = self.n             # <<<<<<<<<<<<<<
 * 		cdef double w, prob = 0.0
 * 
 */
    __pyx_t_1 = __pyx_v_self->n;
    __pyx_v_n = __pyx_t_1;

    /* "pomegranate/distributions.pyx":1513
 * 
 * 		cdef int i, n = self.n
 * 		cdef double w, prob = 0.0             # <<<<<<<<<<<<<<
 * 
 * 		for i in range( n ):
 */
    __pyx_v_prob = 0.0;

    /* "pomegranate/distributions.pyx":1515
 * 		cdef double w, prob = 0.0
 * 
 * 		for i in range( n ):             # <<<<<<<<<<<<<<
 * 			with gil:
 * 				w = self.weights_p[i]
 */
    __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;

      /* "pomegranate/distributions.pyx":1516
 * 
 * 		for i in range( n ):
 * 			with gil:             # <<<<<<<<<<<<<<
 * 				w = self.weights_p[i]
 * 				d = self.distributions[i]
 */
      {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
          #endif
          /*try:*/ {

            /* "pomegranate/distributions.pyx":1517
 * 		for i in range( n ):
 * 			with gil:
 * 				w = self.weights_p[i]             # <<<<<<<<<<<<<<
 * 				d = self.distributions[i]
 * 				prob += cexp( d.log_probability( symbol ) ) * w
 */
            __pyx_v_w = (__pyx_v_self->weights_p[__pyx_v_i]);

            /* "pomegranate/distributions.pyx":1518
 * 			with gil:
 * 				w = self.weights_p[i]
 * 				d = self.distributions[i]             # <<<<<<<<<<<<<<
 * 				prob += cexp( d.log_probability( symbol ) ) * w
 * 
 */
            __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->distributions), __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1518; __pyx_clineno = __LINE__; goto __pyx_L11_error;};
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_3);
            __pyx_t_3 = 0;

            /* "pomegranate/distributions.pyx":1519
 * 				w = self.weights_p[i]
 * 				d = self.distributions[i]
 * 				prob += cexp( d.log_probability( symbol ) ) * w             # <<<<<<<<<<<<<<
 * 
 * 		return _log( prob )
 */
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_log_probability); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1519; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_5 = PyFloat_FromDouble(__pyx_v_symbol); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1519; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_6 = NULL;
            if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
              __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
              if (likely(__pyx_t_6)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
                __Pyx_INCREF(__pyx_t_6);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_4, function);
              }
            }
            if (!__pyx_t_6) {
              __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1519; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_GOTREF(__pyx_t_3);
            } else {
              __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1519; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
              __Pyx_GIVEREF(__pyx_t_5);
              PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
              __pyx_t_5 = 0;
              __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1519; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            }
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1519; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_v_prob = (__pyx_v_prob + (exp(__pyx_t_8) * __pyx_v_w));
          }

          /* "pomegranate/distributions.pyx":1516
 * 
 * 		for i in range( n ):
 * 			with gil:             # <<<<<<<<<<<<<<
 * 				w = self.weights_p[i]
 * 				d = self.distributions[i]
 */
          /*finally:*/ {
            /*normal exit:*/{
              #ifdef WITH_THREAD
              PyGILState_Release(__pyx_gilstate_save);
              #endif
              goto __pyx_L12;
            }
            __pyx_L11_error: {
              #ifdef WITH_THREAD
              PyGILState_Release(__pyx_gilstate_save);
              #endif
              goto __pyx_L4_error;
            }
            __pyx_L12:;
          }
      }
    }

    /* "pomegranate/distributions.pyx":1521
 * 				prob += cexp( d.log_probability( symbol ) ) * w
 * 
 * 		return _log( prob )             # <<<<<<<<<<<<<<
 * 
 * 	def sample( self ):
 */
    __pyx_r = __pyx_f_11pomegranate_5utils__log(__pyx_v_prob);
    goto __pyx_L3_return;
  }

  /* "pomegranate/distributions.pyx":1510
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:
 * 		"""Cython optimized function for log probability calculation."""             # <<<<<<<<<<<<<<
 * 
 * 		cdef int i, n = self.n
 */
  /*finally:*/ {
    __pyx_L3_return: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L0;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
  }

  /* "pomegranate/distributions.pyx":1509
 * 		self.frozen = frozen
 * 
 * 	cdef double _log_probability( self, double symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("pomegranate.distributions.MixtureDistribution._log_probability", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 1);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_d);
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1523
 * 		return _log( prob )
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Sample from the mixture. First, choose a distribution to sample from
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_19MixtureDistribution_2sample[] = "\n\t\tSample from the mixture. First, choose a distribution to sample from\n\t\taccording to the weights, then sample from that distribution. \n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_3sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_19MixtureDistribution_2sample(((struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_19MixtureDistribution_2sample(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self) {
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_d = NULL;
  PyObject *__pyx_v_w = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);

  /* "pomegranate/distributions.pyx":1529
 * 		"""
 * 
 * 		i = random.random()             # <<<<<<<<<<<<<<
 * 		for d, w in izip( *self.parameters ):
 * 			if w > i:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_i = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1530
 * 
 * 		i = random.random()
 * 		for d, w in izip( *self.parameters ):             # <<<<<<<<<<<<<<
 * 			if w > i:
 * 				return d.sample()
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_izip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
      PyObject* sequence = __pyx_t_3;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_1 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_w, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "pomegranate/distributions.pyx":1531
 * 		i = random.random()
 * 		for d, w in izip( *self.parameters ):
 * 			if w > i:             # <<<<<<<<<<<<<<
 * 				return d.sample()
 * 			i -= w
 */
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_w, __pyx_v_i, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_9) {

      /* "pomegranate/distributions.pyx":1532
 * 		for d, w in izip( *self.parameters ):
 * 			if w > i:
 * 				return d.sample()             # <<<<<<<<<<<<<<
 * 			i -= w
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_sample); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (__pyx_t_1) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L0;

      /* "pomegranate/distributions.pyx":1531
 * 		i = random.random()
 * 		for d, w in izip( *self.parameters ):
 * 			if w > i:             # <<<<<<<<<<<<<<
 * 				return d.sample()
 * 			i -= w
 */
    }

    /* "pomegranate/distributions.pyx":1533
 * 			if w > i:
 * 				return d.sample()
 * 			i -= w             # <<<<<<<<<<<<<<
 * 
 * 	def from_sample( self, items, weights=None ):
 */
    __pyx_t_3 = PyNumber_InPlaceSubtract(__pyx_v_i, __pyx_v_w); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_i, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":1530
 * 
 * 		i = random.random()
 * 		for d, w in izip( *self.parameters ):             # <<<<<<<<<<<<<<
 * 			if w > i:
 * 				return d.sample()
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":1523
 * 		return _log( prob )
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Sample from the mixture. First, choose a distribution to sample from
 */

  /* function exit code */
  __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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.MixtureDistribution.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_d);
  __Pyx_XDECREF(__pyx_v_w);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1535
 * 			i -= w
 * 
 * 	def from_sample( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Perform EM to estimate the parameters of each distribution
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_5from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_19MixtureDistribution_4from_sample[] = "\n\t\tPerform EM to estimate the parameters of each distribution\n\t\twhich is a part of this mixture.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_5from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1535; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_sample", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1535; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.MixtureDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_19MixtureDistribution_4from_sample(((struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_19MixtureDistribution_4from_sample(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights) {
  PyObject *__pyx_v_distributions = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_w = NULL;
  Py_ssize_t __pyx_v_n;
  Py_ssize_t __pyx_v_k;
  PyObject *__pyx_v_r = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_distribution = NULL;
  PyObject *__pyx_v_j = NULL;
  PyObject *__pyx_v_item = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *(*__pyx_t_12)(PyObject *);
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_sample", 0);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":1541
 * 		"""
 * 
 * 		if weights is None:             # <<<<<<<<<<<<<<
 * 			weights = numpy.ones( len(items) )
 * 		else:
 */
  __pyx_t_1 = (__pyx_v_weights == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pomegranate/distributions.pyx":1542
 * 
 * 		if weights is None:
 * 			weights = numpy.ones( len(items) )             # <<<<<<<<<<<<<<
 * 		else:
 * 			weights = numpy.asarray( weights )
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ones); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":1541
 * 		"""
 * 
 * 		if weights is None:             # <<<<<<<<<<<<<<
 * 			weights = numpy.ones( len(items) )
 * 		else:
 */
    goto __pyx_L3;
  }

  /* "pomegranate/distributions.pyx":1544
 * 			weights = numpy.ones( len(items) )
 * 		else:
 * 			weights = numpy.asarray( weights )             # <<<<<<<<<<<<<<
 * 
 * 		if weights.sum() == 0:
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_asarray); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_weights); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_INCREF(__pyx_v_weights);
      __Pyx_GIVEREF(__pyx_v_weights);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_weights);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "pomegranate/distributions.pyx":1546
 * 			weights = numpy.asarray( weights )
 * 
 * 		if weights.sum() == 0:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_weights, __pyx_n_s_sum); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__pyx_t_2) {

    /* "pomegranate/distributions.pyx":1547
 * 
 * 		if weights.sum() == 0:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		distributions, w = self.parameters
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":1546
 * 			weights = numpy.asarray( weights )
 * 
 * 		if weights.sum() == 0:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":1549
 * 			return
 * 
 * 		distributions, w = self.parameters             # <<<<<<<<<<<<<<
 * 		n, k = len(items), len(distributions)
 * 
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
    PyObject* sequence = __pyx_t_8;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_5 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_9 = Py_TYPE(__pyx_t_5)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_9(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_4 = __pyx_t_9(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_9 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L6_unpacking_done:;
  }
  __pyx_v_distributions = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_w = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1550
 * 
 * 		distributions, w = self.parameters
 * 		n, k = len(items), len(distributions)             # <<<<<<<<<<<<<<
 * 
 * 		# The responsibility matrix
 */
  __pyx_t_6 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_10 = PyObject_Length(__pyx_v_distributions); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_n = __pyx_t_6;
  __pyx_v_k = __pyx_t_10;

  /* "pomegranate/distributions.pyx":1553
 * 
 * 		# The responsibility matrix
 * 		r = numpy.zeros( (n, k) )             # <<<<<<<<<<<<<<
 * 
 * 		# Calculate the log probabilities of each p
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_k); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_8);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_r = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "pomegranate/distributions.pyx":1556
 * 
 * 		# Calculate the log probabilities of each p
 * 		for i, distribution in enumerate( distributions ):             # <<<<<<<<<<<<<<
 * 			for j, item in enumerate( items ):
 * 				r[j, i] = distribution.log_probability( item )
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_8 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_distributions)) || PyTuple_CheckExact(__pyx_v_distributions)) {
    __pyx_t_3 = __pyx_v_distributions; __Pyx_INCREF(__pyx_t_3); __pyx_t_10 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_10 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_distributions); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_11)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_11(__pyx_t_3);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_distribution, __pyx_t_4);
    __pyx_t_4 = 0;
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_8);
    __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_t_8, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_8);
    __pyx_t_8 = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":1557
 * 		# Calculate the log probabilities of each p
 * 		for i, distribution in enumerate( distributions ):
 * 			for j, item in enumerate( items ):             # <<<<<<<<<<<<<<
 * 				r[j, i] = distribution.log_probability( item )
 * 
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_4 = __pyx_int_0;
    if (likely(PyList_CheckExact(__pyx_v_items)) || PyTuple_CheckExact(__pyx_v_items)) {
      __pyx_t_7 = __pyx_v_items; __Pyx_INCREF(__pyx_t_7); __pyx_t_6 = 0;
      __pyx_t_12 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_items); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_12 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_12)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_7, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_7, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        }
      } else {
        __pyx_t_5 = __pyx_t_12(__pyx_t_7);
        if (unlikely(!__pyx_t_5)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_5);
      __pyx_t_5 = 0;
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_4);
      __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_4, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4);
      __pyx_t_4 = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "pomegranate/distributions.pyx":1558
 * 		for i, distribution in enumerate( distributions ):
 * 			for j, item in enumerate( items ):
 * 				r[j, i] = distribution.log_probability( item )             # <<<<<<<<<<<<<<
 * 
 * 		r = numpy.exp( r )
 */
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_distribution, __pyx_n_s_log_probability); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_13))) {
        __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
        if (likely(__pyx_t_14)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_13, function);
        }
      }
      if (!__pyx_t_14) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_v_item); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
      } else {
        __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
        __Pyx_INCREF(__pyx_v_item);
        __Pyx_GIVEREF(__pyx_v_item);
        PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_v_item);
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_15, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_INCREF(__pyx_v_j);
      __Pyx_GIVEREF(__pyx_v_j);
      PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_j);
      __Pyx_INCREF(__pyx_v_i);
      __Pyx_GIVEREF(__pyx_v_i);
      PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_i);
      if (unlikely(PyObject_SetItem(__pyx_v_r, __pyx_t_13, __pyx_t_5) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "pomegranate/distributions.pyx":1557
 * 		# Calculate the log probabilities of each p
 * 		for i, distribution in enumerate( distributions ):
 * 			for j, item in enumerate( items ):             # <<<<<<<<<<<<<<
 * 				r[j, i] = distribution.log_probability( item )
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":1556
 * 
 * 		# Calculate the log probabilities of each p
 * 		for i, distribution in enumerate( distributions ):             # <<<<<<<<<<<<<<
 * 			for j, item in enumerate( items ):
 * 				r[j, i] = distribution.log_probability( item )
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "pomegranate/distributions.pyx":1560
 * 				r[j, i] = distribution.log_probability( item )
 * 
 * 		r = numpy.exp( r )             # <<<<<<<<<<<<<<
 * 
 * 		# Turn these log probabilities into responsibilities by
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_exp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_r); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_r);
    __Pyx_GIVEREF(__pyx_v_r);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_r);
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF_SET(__pyx_v_r, __pyx_t_8);
  __pyx_t_8 = 0;

  /* "pomegranate/distributions.pyx":1564
 * 		# Turn these log probabilities into responsibilities by
 * 		# normalizing on a row-by-row manner.
 * 		for i in xrange( n ):             # <<<<<<<<<<<<<<
 * 			r[i] = r[i] / r[i].sum()
 * 
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_xrange); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_8);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(PyList_CheckExact(__pyx_t_8)) || PyTuple_CheckExact(__pyx_t_8)) {
    __pyx_t_4 = __pyx_t_8; __Pyx_INCREF(__pyx_t_4); __pyx_t_10 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_10 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_11 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  for (;;) {
    if (likely(!__pyx_t_11)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_8 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      } else {
        if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      }
    } else {
      __pyx_t_8 = __pyx_t_11(__pyx_t_4);
      if (unlikely(!__pyx_t_8)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_8);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "pomegranate/distributions.pyx":1565
 * 		# normalizing on a row-by-row manner.
 * 		for i in xrange( n ):
 * 			r[i] = r[i] / r[i].sum()             # <<<<<<<<<<<<<<
 * 
 * 		# Weight the responsibilities by the given weights
 */
    __pyx_t_8 = PyObject_GetItem(__pyx_v_r, __pyx_v_i); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = PyObject_GetItem(__pyx_v_r, __pyx_v_i); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_8, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(PyObject_SetItem(__pyx_v_r, __pyx_v_i, __pyx_t_3) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":1564
 * 		# Turn these log probabilities into responsibilities by
 * 		# normalizing on a row-by-row manner.
 * 		for i in xrange( n ):             # <<<<<<<<<<<<<<
 * 			r[i] = r[i] / r[i].sum()
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1568
 * 
 * 		# Weight the responsibilities by the given weights
 * 		for i in xrange( k ):             # <<<<<<<<<<<<<<
 * 			r[:,i] = r[:,i]*weights
 * 
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_xrange); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_k); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_10 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_10 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (likely(!__pyx_t_11)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_11(__pyx_t_3);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":1569
 * 		# Weight the responsibilities by the given weights
 * 		for i in xrange( k ):
 * 			r[:,i] = r[:,i]*weights             # <<<<<<<<<<<<<<
 * 
 * 		# Update the emissions of each distribution
 */
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_slice__19);
    __Pyx_GIVEREF(__pyx_slice__19);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__19);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_i);
    __pyx_t_7 = PyObject_GetItem(__pyx_v_r, __pyx_t_4); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_7, __pyx_v_weights); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_slice__20);
    __Pyx_GIVEREF(__pyx_slice__20);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_slice__20);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_i);
    if (unlikely(PyObject_SetItem(__pyx_v_r, __pyx_t_7, __pyx_t_4) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":1568
 * 
 * 		# Weight the responsibilities by the given weights
 * 		for i in xrange( k ):             # <<<<<<<<<<<<<<
 * 			r[:,i] = r[:,i]*weights
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":1572
 * 
 * 		# Update the emissions of each distribution
 * 		for i, distribution in enumerate( distributions ):             # <<<<<<<<<<<<<<
 * 			distribution.from_sample( items, weights=r[:,i] )
 * 
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_3 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_distributions)) || PyTuple_CheckExact(__pyx_v_distributions)) {
    __pyx_t_4 = __pyx_v_distributions; __Pyx_INCREF(__pyx_t_4); __pyx_t_10 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_10 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_distributions); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_11 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_11)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_7); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      } else {
        if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_7); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      }
    } else {
      __pyx_t_7 = __pyx_t_11(__pyx_t_4);
      if (unlikely(!__pyx_t_7)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_7);
    }
    __Pyx_XDECREF_SET(__pyx_v_distribution, __pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
    __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_3 = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "pomegranate/distributions.pyx":1573
 * 		# Update the emissions of each distribution
 * 		for i, distribution in enumerate( distributions ):
 * 			distribution.from_sample( items, weights=r[:,i] )             # <<<<<<<<<<<<<<
 * 
 * 		# Update the weight of each distribution
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_distribution, __pyx_n_s_from_sample); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_items);
    __Pyx_GIVEREF(__pyx_v_items);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_items);
    __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_INCREF(__pyx_slice__21);
    __Pyx_GIVEREF(__pyx_slice__21);
    PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_slice__21);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_i);
    __pyx_t_15 = PyObject_GetItem(__pyx_v_r, __pyx_t_13); if (unlikely(__pyx_t_15 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1573; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_weights, __pyx_t_15) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

    /* "pomegranate/distributions.pyx":1572
 * 
 * 		# Update the emissions of each distribution
 * 		for i, distribution in enumerate( distributions ):             # <<<<<<<<<<<<<<
 * 			distribution.from_sample( items, weights=r[:,i] )
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":1576
 * 
 * 		# Update the weight of each distribution
 * 		self.weights = r.sum( axis=0 ) / r.sum()             # <<<<<<<<<<<<<<
 * 
 * 	def summarize( self, items, weights=None ):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_r, __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_axis, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_r, __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_8) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_15, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->weights));
  __pyx_v_self->weights = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":1535
 * 			i -= w
 * 
 * 	def from_sample( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Perform EM to estimate the parameters of each distribution
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("pomegranate.distributions.MixtureDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_distributions);
  __Pyx_XDECREF(__pyx_v_w);
  __Pyx_XDECREF(__pyx_v_r);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_distribution);
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1578
 * 		self.weights = r.sum( axis=0 ) / r.sum()
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Performs the summary step of the EM algorithm to estimate
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_7summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_19MixtureDistribution_6summarize[] = "\n\t\tPerforms the summary step of the EM algorithm to estimate\n\t\tparameters of each distribution which is a part of this mixture.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_7summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("summarize (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "summarize") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1578; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("summarize", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1578; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.MixtureDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_19MixtureDistribution_6summarize(((struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_19MixtureDistribution_6summarize(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights) {
  PyObject *__pyx_v_distributions = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_w = NULL;
  Py_ssize_t __pyx_v_n;
  Py_ssize_t __pyx_v_k;
  PyObject *__pyx_v_r = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_distribution = NULL;
  PyObject *__pyx_v_j = NULL;
  PyObject *__pyx_v_item = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *(*__pyx_t_12)(PyObject *);
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("summarize", 0);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":1584
 * 		"""
 * 
 * 		if weights is None:             # <<<<<<<<<<<<<<
 * 			weights = numpy.ones( len(items) )
 * 		else:
 */
  __pyx_t_1 = (__pyx_v_weights == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pomegranate/distributions.pyx":1585
 * 
 * 		if weights is None:
 * 			weights = numpy.ones( len(items) )             # <<<<<<<<<<<<<<
 * 		else:
 * 			weights = numpy.asarray( weights )
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ones); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":1584
 * 		"""
 * 
 * 		if weights is None:             # <<<<<<<<<<<<<<
 * 			weights = numpy.ones( len(items) )
 * 		else:
 */
    goto __pyx_L3;
  }

  /* "pomegranate/distributions.pyx":1587
 * 			weights = numpy.ones( len(items) )
 * 		else:
 * 			weights = numpy.asarray( weights )             # <<<<<<<<<<<<<<
 * 
 * 		if weights.sum() == 0:
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_asarray); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_weights); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_INCREF(__pyx_v_weights);
      __Pyx_GIVEREF(__pyx_v_weights);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_weights);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "pomegranate/distributions.pyx":1589
 * 			weights = numpy.asarray( weights )
 * 
 * 		if weights.sum() == 0:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_weights, __pyx_n_s_sum); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__pyx_t_2) {

    /* "pomegranate/distributions.pyx":1590
 * 
 * 		if weights.sum() == 0:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		distributions, w = self.parameters
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":1589
 * 			weights = numpy.asarray( weights )
 * 
 * 		if weights.sum() == 0:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":1592
 * 			return
 * 
 * 		distributions, w = self.parameters             # <<<<<<<<<<<<<<
 * 		n, k = len(items), len(distributions)
 * 
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
    PyObject* sequence = __pyx_t_8;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_5 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_9 = Py_TYPE(__pyx_t_5)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_9(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_4 = __pyx_t_9(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_9 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L6_unpacking_done:;
  }
  __pyx_v_distributions = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_w = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1593
 * 
 * 		distributions, w = self.parameters
 * 		n, k = len(items), len(distributions)             # <<<<<<<<<<<<<<
 * 
 * 		# The responsibility matrix
 */
  __pyx_t_6 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_10 = PyObject_Length(__pyx_v_distributions); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_n = __pyx_t_6;
  __pyx_v_k = __pyx_t_10;

  /* "pomegranate/distributions.pyx":1596
 * 
 * 		# The responsibility matrix
 * 		r = numpy.zeros( (n, k) )             # <<<<<<<<<<<<<<
 * 
 * 		# Calculate the log probabilities of each p
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_k); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_8);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_r = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "pomegranate/distributions.pyx":1599
 * 
 * 		# Calculate the log probabilities of each p
 * 		for i, distribution in enumerate( distributions ):             # <<<<<<<<<<<<<<
 * 			for j, item in enumerate( items ):
 * 				r[j, i] = distribution.log_probability( item )
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_8 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_distributions)) || PyTuple_CheckExact(__pyx_v_distributions)) {
    __pyx_t_3 = __pyx_v_distributions; __Pyx_INCREF(__pyx_t_3); __pyx_t_10 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_10 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_distributions); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_11)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_11(__pyx_t_3);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_distribution, __pyx_t_4);
    __pyx_t_4 = 0;
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_8);
    __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_t_8, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_8);
    __pyx_t_8 = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":1600
 * 		# Calculate the log probabilities of each p
 * 		for i, distribution in enumerate( distributions ):
 * 			for j, item in enumerate( items ):             # <<<<<<<<<<<<<<
 * 				r[j, i] = distribution.log_probability( item )
 * 
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_4 = __pyx_int_0;
    if (likely(PyList_CheckExact(__pyx_v_items)) || PyTuple_CheckExact(__pyx_v_items)) {
      __pyx_t_7 = __pyx_v_items; __Pyx_INCREF(__pyx_t_7); __pyx_t_6 = 0;
      __pyx_t_12 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_items); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_12 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_12)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_7, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_7, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          #endif
        }
      } else {
        __pyx_t_5 = __pyx_t_12(__pyx_t_7);
        if (unlikely(!__pyx_t_5)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_5);
      __pyx_t_5 = 0;
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_4);
      __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_4, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4);
      __pyx_t_4 = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "pomegranate/distributions.pyx":1601
 * 		for i, distribution in enumerate( distributions ):
 * 			for j, item in enumerate( items ):
 * 				r[j, i] = distribution.log_probability( item )             # <<<<<<<<<<<<<<
 * 
 * 		r = numpy.exp( r )
 */
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_distribution, __pyx_n_s_log_probability); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_13))) {
        __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
        if (likely(__pyx_t_14)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_13, function);
        }
      }
      if (!__pyx_t_14) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_v_item); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
      } else {
        __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
        __Pyx_INCREF(__pyx_v_item);
        __Pyx_GIVEREF(__pyx_v_item);
        PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_v_item);
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_15, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_INCREF(__pyx_v_j);
      __Pyx_GIVEREF(__pyx_v_j);
      PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_j);
      __Pyx_INCREF(__pyx_v_i);
      __Pyx_GIVEREF(__pyx_v_i);
      PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_i);
      if (unlikely(PyObject_SetItem(__pyx_v_r, __pyx_t_13, __pyx_t_5) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "pomegranate/distributions.pyx":1600
 * 		# Calculate the log probabilities of each p
 * 		for i, distribution in enumerate( distributions ):
 * 			for j, item in enumerate( items ):             # <<<<<<<<<<<<<<
 * 				r[j, i] = distribution.log_probability( item )
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":1599
 * 
 * 		# Calculate the log probabilities of each p
 * 		for i, distribution in enumerate( distributions ):             # <<<<<<<<<<<<<<
 * 			for j, item in enumerate( items ):
 * 				r[j, i] = distribution.log_probability( item )
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "pomegranate/distributions.pyx":1603
 * 				r[j, i] = distribution.log_probability( item )
 * 
 * 		r = numpy.exp( r )             # <<<<<<<<<<<<<<
 * 
 * 		# Turn these log probabilities into responsibilities by
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_exp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_r); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_r);
    __Pyx_GIVEREF(__pyx_v_r);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_r);
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF_SET(__pyx_v_r, __pyx_t_8);
  __pyx_t_8 = 0;

  /* "pomegranate/distributions.pyx":1607
 * 		# Turn these log probabilities into responsibilities by
 * 		# normalizing on a row-by-row manner.
 * 		for i in xrange( n ):             # <<<<<<<<<<<<<<
 * 			r[i] = r[i] / r[i].sum()
 * 
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_xrange); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_8);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(PyList_CheckExact(__pyx_t_8)) || PyTuple_CheckExact(__pyx_t_8)) {
    __pyx_t_4 = __pyx_t_8; __Pyx_INCREF(__pyx_t_4); __pyx_t_10 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_10 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_11 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  for (;;) {
    if (likely(!__pyx_t_11)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_8 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      } else {
        if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      }
    } else {
      __pyx_t_8 = __pyx_t_11(__pyx_t_4);
      if (unlikely(!__pyx_t_8)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_8);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "pomegranate/distributions.pyx":1608
 * 		# normalizing on a row-by-row manner.
 * 		for i in xrange( n ):
 * 			r[i] = r[i] / r[i].sum()             # <<<<<<<<<<<<<<
 * 
 * 		# Weight the responsibilities by the given weights
 */
    __pyx_t_8 = PyObject_GetItem(__pyx_v_r, __pyx_v_i); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = PyObject_GetItem(__pyx_v_r, __pyx_v_i); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_8, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(PyObject_SetItem(__pyx_v_r, __pyx_v_i, __pyx_t_3) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":1607
 * 		# Turn these log probabilities into responsibilities by
 * 		# normalizing on a row-by-row manner.
 * 		for i in xrange( n ):             # <<<<<<<<<<<<<<
 * 			r[i] = r[i] / r[i].sum()
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1611
 * 
 * 		# Weight the responsibilities by the given weights
 * 		for i in xrange( k ):             # <<<<<<<<<<<<<<
 * 			r[:,i] = r[:,i]*weights
 * 
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_xrange); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_k); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_10 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_10 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (likely(!__pyx_t_11)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_11(__pyx_t_3);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":1612
 * 		# Weight the responsibilities by the given weights
 * 		for i in xrange( k ):
 * 			r[:,i] = r[:,i]*weights             # <<<<<<<<<<<<<<
 * 
 * 		# Save summary statistics on the emission distributions
 */
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_slice__22);
    __Pyx_GIVEREF(__pyx_slice__22);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__22);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_i);
    __pyx_t_7 = PyObject_GetItem(__pyx_v_r, __pyx_t_4); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1612; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_7, __pyx_v_weights); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_slice__23);
    __Pyx_GIVEREF(__pyx_slice__23);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_slice__23);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_i);
    if (unlikely(PyObject_SetItem(__pyx_v_r, __pyx_t_7, __pyx_t_4) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":1611
 * 
 * 		# Weight the responsibilities by the given weights
 * 		for i in xrange( k ):             # <<<<<<<<<<<<<<
 * 			r[:,i] = r[:,i]*weights
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":1615
 * 
 * 		# Save summary statistics on the emission distributions
 * 		for i, distribution in enumerate( distributions ):             # <<<<<<<<<<<<<<
 * 			distribution.summarize( items, weights=r[:,i]*weights )
 * 
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_3 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_distributions)) || PyTuple_CheckExact(__pyx_v_distributions)) {
    __pyx_t_4 = __pyx_v_distributions; __Pyx_INCREF(__pyx_t_4); __pyx_t_10 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_10 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_distributions); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_11 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_11)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_7); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      } else {
        if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_7); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      }
    } else {
      __pyx_t_7 = __pyx_t_11(__pyx_t_4);
      if (unlikely(!__pyx_t_7)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_7);
    }
    __Pyx_XDECREF_SET(__pyx_v_distribution, __pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
    __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_3 = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "pomegranate/distributions.pyx":1616
 * 		# Save summary statistics on the emission distributions
 * 		for i, distribution in enumerate( distributions ):
 * 			distribution.summarize( items, weights=r[:,i]*weights )             # <<<<<<<<<<<<<<
 * 
 * 		# Save summary statistics for weight updates
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_distribution, __pyx_n_s_summarize); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_items);
    __Pyx_GIVEREF(__pyx_v_items);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_items);
    __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_INCREF(__pyx_slice__24);
    __Pyx_GIVEREF(__pyx_slice__24);
    PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_slice__24);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_i);
    __pyx_t_15 = PyObject_GetItem(__pyx_v_r, __pyx_t_13); if (unlikely(__pyx_t_15 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = PyNumber_Multiply(__pyx_t_15, __pyx_v_weights); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_weights, __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

    /* "pomegranate/distributions.pyx":1615
 * 
 * 		# Save summary statistics on the emission distributions
 * 		for i, distribution in enumerate( distributions ):             # <<<<<<<<<<<<<<
 * 			distribution.summarize( items, weights=r[:,i]*weights )
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":1619
 * 
 * 		# Save summary statistics for weight updates
 * 		self.summaries.append( r.sum( axis=0 ) / r.sum() )             # <<<<<<<<<<<<<<
 * 
 * 	def from_summaries( self, inertia=0.0 ):
 */
  if (unlikely(__pyx_v_self->__pyx_base.summaries == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_r, __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_axis, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_r, __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_8) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_13, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_self->__pyx_base.summaries, __pyx_t_3); if (unlikely(__pyx_t_16 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":1578
 * 		self.weights = r.sum( axis=0 ) / r.sum()
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Performs the summary step of the EM algorithm to estimate
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("pomegranate.distributions.MixtureDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_distributions);
  __Pyx_XDECREF(__pyx_v_w);
  __Pyx_XDECREF(__pyx_v_r);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_distribution);
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1621
 * 		self.summaries.append( r.sum( axis=0 ) / r.sum() )
 * 
 * 	def from_summaries( self, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Performs the actual update step for the EM algorithm.
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_9from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_19MixtureDistribution_8from_summaries[] = "\n\t\tPerforms the actual update step for the EM algorithm.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_9from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_summaries (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_inertia,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_summaries") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1621; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_inertia = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_summaries", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1621; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.MixtureDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_19MixtureDistribution_8from_summaries(((struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *)__pyx_v_self), __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_19MixtureDistribution_8from_summaries(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self, PyObject *__pyx_v_inertia) {
  PyObject *__pyx_v_d = NULL;
  PyObject *__pyx_v_weights = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_summaries", 0);

  /* "pomegranate/distributions.pyx":1627
 * 
 * 		# If this distribution is frozen, don't do anything.
 * 		if self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->__pyx_base.frozen == 1) != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":1628
 * 		# If this distribution is frozen, don't do anything.
 * 		if self.frozen == True:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		# Update the emission distributions
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":1627
 * 
 * 		# If this distribution is frozen, don't do anything.
 * 		if self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":1631
 * 
 * 		# Update the emission distributions
 * 		for d in self.distributions:             # <<<<<<<<<<<<<<
 * 			d.from_summaries( inertia=inertia )
 * 
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_v_self->distributions))) || PyTuple_CheckExact(((PyObject *)__pyx_v_self->distributions))) {
    __pyx_t_2 = ((PyObject *)__pyx_v_self->distributions); __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(((PyObject *)__pyx_v_self->distributions)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "pomegranate/distributions.pyx":1632
 * 		# Update the emission distributions
 * 		for d in self.distributions:
 * 			d.from_summaries( inertia=inertia )             # <<<<<<<<<<<<<<
 * 
 * 		# Update the weights
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_from_summaries); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_inertia, __pyx_v_inertia) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "pomegranate/distributions.pyx":1631
 * 
 * 		# Update the emission distributions
 * 		for d in self.distributions:             # <<<<<<<<<<<<<<
 * 			d.from_summaries( inertia=inertia )
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":1635
 * 
 * 		# Update the weights
 * 		weights = numpy.array( self.summaries )             # <<<<<<<<<<<<<<
 * 		self.weights = weights.sum( axis=0 ) / weights.sum()
 * 
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_array); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_self->__pyx_base.summaries); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
    __Pyx_INCREF(__pyx_v_self->__pyx_base.summaries);
    __Pyx_GIVEREF(__pyx_v_self->__pyx_base.summaries);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_self->__pyx_base.summaries);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_weights = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":1636
 * 		# Update the weights
 * 		weights = numpy.array( self.summaries )
 * 		self.weights = weights.sum( axis=0 ) / weights.sum()             # <<<<<<<<<<<<<<
 * 
 * 	def to_json( self ):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_weights, __pyx_n_s_sum); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_axis, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_weights, __pyx_n_s_sum); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_7) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else {
    __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->weights));
  __pyx_v_self->weights = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":1621
 * 		self.summaries.append( r.sum( axis=0 ) / r.sum() )
 * 
 * 	def from_summaries( self, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Performs the actual update step for the EM algorithm.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.MixtureDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_d);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1638
 * 		self.weights = weights.sum( axis=0 ) / weights.sum()
 * 
 * 	def to_json( self ):             # <<<<<<<<<<<<<<
 * 		"""Convert the distribution to JSON format."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_11to_json(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_19MixtureDistribution_10to_json[] = "Convert the distribution to JSON format.";
static PyObject *__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_11to_json(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_json (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_19MixtureDistribution_10to_json(((struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_19MixtureDistribution_10to_json(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *__pyx_v_self) {
  PyObject *__pyx_v_dist = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_json", 0);

  /* "pomegranate/distributions.pyx":1641
 * 		"""Convert the distribution to JSON format."""
 * 
 * 		return json.dumps( {             # <<<<<<<<<<<<<<
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_json); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dumps); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1642
 * 
 * 		return json.dumps( {
 * 								'class' : 'Distribution',             # <<<<<<<<<<<<<<
 * 								'name'  : self.name,
 * 								'parameters' : [ [ dist.to_json() for dist in self.parameters[0] ],
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_class_2, __pyx_n_s_Distribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "pomegranate/distributions.pyx":1643
 * 		return json.dumps( {
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,             # <<<<<<<<<<<<<<
 * 								'parameters' : [ [ dist.to_json() for dist in self.parameters[0] ],
 * 								                 self.parameters[1] ],
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_self->__pyx_base.name) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "pomegranate/distributions.pyx":1644
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,
 * 								'parameters' : [ [ dist.to_json() for dist in self.parameters[0] ],             # <<<<<<<<<<<<<<
 * 								                 self.parameters[1] ],
 * 								'frozen' : self.frozen
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
    __pyx_t_4 = __pyx_t_5; __Pyx_INCREF(__pyx_t_4); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_7(__pyx_t_4);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_dist, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_dist, __pyx_n_s_to_json); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (__pyx_t_9) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else {
      __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1645
 * 								'name'  : self.name,
 * 								'parameters' : [ [ dist.to_json() for dist in self.parameters[0] ],
 * 								                 self.parameters[1] ],             # <<<<<<<<<<<<<<
 * 								'frozen' : self.frozen
 * 						   }, separators=(',', ' : ' ), indent=4 )
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1644
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,
 * 								'parameters' : [ [ dist.to_json() for dist in self.parameters[0] ],             # <<<<<<<<<<<<<<
 * 								                 self.parameters[1] ],
 * 								'frozen' : self.frozen
 */
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
  __pyx_t_3 = 0;
  __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_parameters, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1646
 * 								'parameters' : [ [ dist.to_json() for dist in self.parameters[0] ],
 * 								                 self.parameters[1] ],
 * 								'frozen' : self.frozen             # <<<<<<<<<<<<<<
 * 						   }, separators=(',', ' : ' ), indent=4 )
 * 
 */
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_self->__pyx_base.frozen); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_frozen, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1641
 * 		"""Convert the distribution to JSON format."""
 * 
 * 		return json.dumps( {             # <<<<<<<<<<<<<<
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,
 */
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1647
 * 								                 self.parameters[1] ],
 * 								'frozen' : self.frozen
 * 						   }, separators=(',', ' : ' ), indent=4 )             # <<<<<<<<<<<<<<
 * 
 * cdef class MultivariateDistribution( Distribution ):
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_separators, __pyx_tuple__25) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_indent, __pyx_int_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "pomegranate/distributions.pyx":1641
 * 		"""Convert the distribution to JSON format."""
 * 
 * 		return json.dumps( {             # <<<<<<<<<<<<<<
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,
 */
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1638
 * 		self.weights = weights.sum( axis=0 ) / weights.sum()
 * 
 * 	def to_json( self ):             # <<<<<<<<<<<<<<
 * 		"""Convert the distribution to JSON format."""
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pomegranate.distributions.MixtureDistribution.to_json", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_dist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pxd":69
 * 
 * cdef class MultivariateDistribution( Distribution ):
 * 	cdef public SIZE_t d             # <<<<<<<<<<<<<<
 * 
 * cdef class IndependentComponentsDistribution( MultivariateDistribution ):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_24MultivariateDistribution_1d_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_24MultivariateDistribution_1d_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_24MultivariateDistribution_1d___get__(((struct __pyx_obj_11pomegranate_13distributions_MultivariateDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_24MultivariateDistribution_1d___get__(struct __pyx_obj_11pomegranate_13distributions_MultivariateDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_self->d); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.MultivariateDistribution.d.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_24MultivariateDistribution_1d_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_24MultivariateDistribution_1d_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_24MultivariateDistribution_1d_2__set__(((struct __pyx_obj_11pomegranate_13distributions_MultivariateDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_24MultivariateDistribution_1d_2__set__(struct __pyx_obj_11pomegranate_13distributions_MultivariateDistribution *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __Pyx_PyInt_As_Py_intptr_t(__pyx_v_value); if (unlikely((__pyx_t_1 == (npy_intp)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->d = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("pomegranate.distributions.MultivariateDistribution.d.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1670
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [ self.distributions.tolist(), self.weights.tolist() ]
 * 		def __set__( self, parameters ):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_10parameters_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_10parameters_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_10parameters___get__(((struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pomegranate/distributions.pyx":1671
 * 	property parameters:
 * 		def __get__( self ):
 * 			return [ self.distributions.tolist(), self.weights.tolist() ]             # <<<<<<<<<<<<<<
 * 		def __set__( self, parameters ):
 * 			self.distributions = numpy.asarray( parameters[0], dtype=numpy.object_ )
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->distributions), __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->weights), __pyx_n_s_tolist); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1670
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [ self.distributions.tolist(), self.weights.tolist() ]
 * 		def __set__( self, parameters ):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pomegranate.distributions.IndependentComponentsDistribution.parameters.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1672
 * 		def __get__( self ):
 * 			return [ self.distributions.tolist(), self.weights.tolist() ]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.distributions = numpy.asarray( parameters[0], dtype=numpy.object_ )
 * 			self.weights = numpy.array( parameters[1] )
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_10parameters_2__set__(((struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_parameters));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "pomegranate/distributions.pyx":1673
 * 			return [ self.distributions.tolist(), self.weights.tolist() ]
 * 		def __set__( self, parameters ):
 * 			self.distributions = numpy.asarray( parameters[0], dtype=numpy.object_ )             # <<<<<<<<<<<<<<
 * 			self.weights = numpy.array( parameters[1] )
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_parameters, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_object); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_GOTREF(__pyx_v_self->distributions);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->distributions));
  __pyx_v_self->distributions = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1674
 * 		def __set__( self, parameters ):
 * 			self.distributions = numpy.asarray( parameters[0], dtype=numpy.object_ )
 * 			self.weights = numpy.array( parameters[1] )             # <<<<<<<<<<<<<<
 * 
 * 	def __cinit__( self, distributions, weights=None, frozen=False ):
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_parameters, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1674; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_GOTREF(__pyx_v_self->weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->weights));
  __pyx_v_self->weights = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1672
 * 		def __get__( self ):
 * 			return [ self.distributions.tolist(), self.weights.tolist() ]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.distributions = numpy.asarray( parameters[0], dtype=numpy.object_ )
 * 			self.weights = numpy.array( parameters[1] )
 */

  /* function exit code */
  __pyx_r = 0;
  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);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pomegranate.distributions.IndependentComponentsDistribution.parameters.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1676
 * 			self.weights = numpy.array( parameters[1] )
 * 
 * 	def __cinit__( self, distributions, weights=None, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in the distributions and appropriate weights. If no weights
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_distributions = 0;
  PyObject *__pyx_v_weights = 0;
  PyObject *__pyx_v_frozen = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_distributions,&__pyx_n_s_weights,&__pyx_n_s_frozen,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_distributions)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1676; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_distributions = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_frozen = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1676; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.IndependentComponentsDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution___cinit__(((struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *)__pyx_v_self), __pyx_v_distributions, __pyx_v_weights, __pyx_v_frozen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self, PyObject *__pyx_v_distributions, PyObject *__pyx_v_weights, PyObject *__pyx_v_frozen) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);
  __Pyx_INCREF(__pyx_v_distributions);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":1683
 * 		"""
 * 
 * 		distributions = numpy.array( distributions, dtype=numpy.object_ )             # <<<<<<<<<<<<<<
 * 		self.d = len(distributions)
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_distributions);
  __Pyx_GIVEREF(__pyx_v_distributions);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_distributions);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_object); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_distributions, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1684
 * 
 * 		distributions = numpy.array( distributions, dtype=numpy.object_ )
 * 		self.d = len(distributions)             # <<<<<<<<<<<<<<
 * 
 * 		if weights:
 */
  __pyx_t_6 = PyObject_Length(__pyx_v_distributions); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->__pyx_base.d = __pyx_t_6;

  /* "pomegranate/distributions.pyx":1686
 * 		self.d = len(distributions)
 * 
 * 		if weights:             # <<<<<<<<<<<<<<
 * 			weights = numpy.array( weights, dtype=numpy.float64 )
 * 		else:
 */
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_weights); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_7) {

    /* "pomegranate/distributions.pyx":1687
 * 
 * 		if weights:
 * 			weights = numpy.array( weights, dtype=numpy.float64 )             # <<<<<<<<<<<<<<
 * 		else:
 * 			weights = numpy.ones( self.d, dtype=numpy.float64 )
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_weights);
    __Pyx_GIVEREF(__pyx_v_weights);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_weights);
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":1686
 * 		self.d = len(distributions)
 * 
 * 		if weights:             # <<<<<<<<<<<<<<
 * 			weights = numpy.array( weights, dtype=numpy.float64 )
 * 		else:
 */
    goto __pyx_L3;
  }

  /* "pomegranate/distributions.pyx":1689
 * 			weights = numpy.array( weights, dtype=numpy.float64 )
 * 		else:
 * 			weights = numpy.ones( self.d, dtype=numpy.float64 )             # <<<<<<<<<<<<<<
 * 
 * 		self.distributions = distributions
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ones); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_self->__pyx_base.d); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float64); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_2);
    __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "pomegranate/distributions.pyx":1691
 * 			weights = numpy.ones( self.d, dtype=numpy.float64 )
 * 
 * 		self.distributions = distributions             # <<<<<<<<<<<<<<
 * 		self.weights = weights
 * 		self.name = "IndependentComponentsDistribution"
 */
  if (!(likely(((__pyx_v_distributions) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_distributions, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __pyx_v_distributions;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->distributions);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->distributions));
  __pyx_v_self->distributions = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":1692
 * 
 * 		self.distributions = distributions
 * 		self.weights = weights             # <<<<<<<<<<<<<<
 * 		self.name = "IndependentComponentsDistribution"
 * 		self.frozen = frozen
 */
  if (!(likely(((__pyx_v_weights) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_weights, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __pyx_v_weights;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->weights));
  __pyx_v_self->weights = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":1693
 * 		self.distributions = distributions
 * 		self.weights = weights
 * 		self.name = "IndependentComponentsDistribution"             # <<<<<<<<<<<<<<
 * 		self.frozen = frozen
 * 
 */
  __Pyx_INCREF(__pyx_n_s_IndependentComponentsDistributio);
  __Pyx_GIVEREF(__pyx_n_s_IndependentComponentsDistributio);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.__pyx_base.name);
  __pyx_v_self->__pyx_base.__pyx_base.name = __pyx_n_s_IndependentComponentsDistributio;

  /* "pomegranate/distributions.pyx":1694
 * 		self.weights = weights
 * 		self.name = "IndependentComponentsDistribution"
 * 		self.frozen = frozen             # <<<<<<<<<<<<<<
 * 
 * 	def log_probability( self, symbol ):
 */
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_frozen); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->__pyx_base.__pyx_base.frozen = __pyx_t_7;

  /* "pomegranate/distributions.pyx":1676
 * 			self.weights = numpy.array( parameters[1] )
 * 
 * 	def __cinit__( self, distributions, weights=None, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in the distributions and appropriate weights. If no weights
 */

  /* function exit code */
  __pyx_r = 0;
  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);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pomegranate.distributions.IndependentComponentsDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_distributions);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1696
 * 		self.frozen = frozen
 * 
 * 	def log_probability( self, symbol ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		What's the probability of a given tuple under this mixture? It's the
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_3log_probability(PyObject *__pyx_v_self, PyObject *__pyx_v_symbol); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_33IndependentComponentsDistribution_2log_probability[] = "\n\t\tWhat's the probability of a given tuple under this mixture? It's the\n\t\tproduct of the probabilities of each symbol in the tuple under their\n\t\trespective distribution, which is the sum of the log probabilities.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_3log_probability(PyObject *__pyx_v_self, PyObject *__pyx_v_symbol) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("log_probability (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_2log_probability(((struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_symbol));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_2log_probability(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self, PyObject *__pyx_v_symbol) {
  PyArrayObject *__pyx_v_symbol_ndarray = 0;
  double *__pyx_v_symbol_ptr;
  double __pyx_v_logp;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("log_probability", 0);

  /* "pomegranate/distributions.pyx":1703
 * 		"""
 * 
 * 		cdef numpy.ndarray symbol_ndarray = numpy.array(symbol).astype( numpy.float64 )             # <<<<<<<<<<<<<<
 * 		cdef double* symbol_ptr = <double*> symbol_ndarray.data
 * 		cdef double logp
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_symbol); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_symbol);
    __Pyx_GIVEREF(__pyx_v_symbol);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_symbol);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_astype); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_symbol_ndarray = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1704
 * 
 * 		cdef numpy.ndarray symbol_ndarray = numpy.array(symbol).astype( numpy.float64 )
 * 		cdef double* symbol_ptr = <double*> symbol_ndarray.data             # <<<<<<<<<<<<<<
 * 		cdef double logp
 * 
 */
  __pyx_v_symbol_ptr = ((double *)__pyx_v_symbol_ndarray->data);

  /* "pomegranate/distributions.pyx":1707
 * 		cdef double logp
 * 
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			logp = self._mv_log_probability( symbol_ptr )
 * 		return logp
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "pomegranate/distributions.pyx":1708
 * 
 * 		with nogil:
 * 			logp = self._mv_log_probability( symbol_ptr )             # <<<<<<<<<<<<<<
 * 		return logp
 * 
 */
        __pyx_v_logp = ((struct __pyx_vtabstruct_11pomegranate_13distributions_IndependentComponentsDistribution *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._mv_log_probability(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), __pyx_v_symbol_ptr);
      }

      /* "pomegranate/distributions.pyx":1707
 * 		cdef double logp
 * 
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			logp = self._mv_log_probability( symbol_ptr )
 * 		return logp
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "pomegranate/distributions.pyx":1709
 * 		with nogil:
 * 			logp = self._mv_log_probability( symbol_ptr )
 * 		return logp             # <<<<<<<<<<<<<<
 * 
 * 	cdef double _mv_log_probability( self, double* symbol ) nogil:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_logp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1696
 * 		self.frozen = frozen
 * 
 * 	def log_probability( self, symbol ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		What's the probability of a given tuple under this mixture? It's the
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pomegranate.distributions.IndependentComponentsDistribution.log_probability", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_symbol_ndarray);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1711
 * 		return logp
 * 
 * 	cdef double _mv_log_probability( self, double* symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

static double __pyx_f_11pomegranate_13distributions_33IndependentComponentsDistribution__mv_log_probability(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self, double *__pyx_v_symbol) {
  int __pyx_v_i;
  int __pyx_v_d;
  double __pyx_v_w;
  double __pyx_v_logp;
  PyObject *__pyx_v_distribution = NULL;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  double __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_mv_log_probability", 0);
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif

  /* "pomegranate/distributions.pyx":1712
 * 
 * 	cdef double _mv_log_probability( self, double* symbol ) nogil:
 * 		"""Cython optimized function for log probability calculation."""             # <<<<<<<<<<<<<<
 * 
 * 		cdef int i, d = self.d
 */
  /*try:*/ {

    /* "pomegranate/distributions.pyx":1714
 * 		"""Cython optimized function for log probability calculation."""
 * 
 * 		cdef int i, d = self.d             # <<<<<<<<<<<<<<
 * 		cdef double w, logp = 0.0
 * 
 */
    __pyx_t_1 = __pyx_v_self->__pyx_base.d;
    __pyx_v_d = __pyx_t_1;

    /* "pomegranate/distributions.pyx":1715
 * 
 * 		cdef int i, d = self.d
 * 		cdef double w, logp = 0.0             # <<<<<<<<<<<<<<
 * 
 * 		with gil:
 */
    __pyx_v_logp = 0.0;

    /* "pomegranate/distributions.pyx":1717
 * 		cdef double w, logp = 0.0
 * 
 * 		with gil:             # <<<<<<<<<<<<<<
 * 			for i in range(d):
 * 				w = self.weights[i]
 */
    {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        /*try:*/ {

          /* "pomegranate/distributions.pyx":1718
 * 
 * 		with gil:
 * 			for i in range(d):             # <<<<<<<<<<<<<<
 * 				w = self.weights[i]
 * 				distribution = self.distributions[i]
 */
          __pyx_t_2 = __pyx_v_d;
          for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
            __pyx_v_i = __pyx_t_3;

            /* "pomegranate/distributions.pyx":1719
 * 		with gil:
 * 			for i in range(d):
 * 				w = self.weights[i]             # <<<<<<<<<<<<<<
 * 				distribution = self.distributions[i]
 * 				logp += distribution.log_probability( symbol[i] ) + _log(w)
 */
            __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->weights), __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 0); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; __pyx_clineno = __LINE__; goto __pyx_L7_error;};
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_v_w = __pyx_t_5;

            /* "pomegranate/distributions.pyx":1720
 * 			for i in range(d):
 * 				w = self.weights[i]
 * 				distribution = self.distributions[i]             # <<<<<<<<<<<<<<
 * 				logp += distribution.log_probability( symbol[i] ) + _log(w)
 * 
 */
            __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->distributions), __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 0); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; __pyx_clineno = __LINE__; goto __pyx_L7_error;};
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_XDECREF_SET(__pyx_v_distribution, __pyx_t_4);
            __pyx_t_4 = 0;

            /* "pomegranate/distributions.pyx":1721
 * 				w = self.weights[i]
 * 				distribution = self.distributions[i]
 * 				logp += distribution.log_probability( symbol[i] ) + _log(w)             # <<<<<<<<<<<<<<
 * 
 * 		return logp
 */
            __pyx_t_4 = PyFloat_FromDouble(__pyx_v_logp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_distribution, __pyx_n_s_log_probability); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_8 = PyFloat_FromDouble((__pyx_v_symbol[__pyx_v_i])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_8);
            __pyx_t_9 = NULL;
            if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
              __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
              if (likely(__pyx_t_9)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
                __Pyx_INCREF(__pyx_t_9);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_7, function);
              }
            }
            if (!__pyx_t_9) {
              __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
              __Pyx_GOTREF(__pyx_t_6);
            } else {
              __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
              __Pyx_GOTREF(__pyx_t_10);
              __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
              __Pyx_GIVEREF(__pyx_t_8);
              PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_8);
              __pyx_t_8 = 0;
              __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            }
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __pyx_t_7 = PyFloat_FromDouble(__pyx_f_11pomegranate_5utils__log(__pyx_v_w)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_10 = PyNumber_Add(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_10); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_7); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __pyx_v_logp = __pyx_t_5;
          }
        }

        /* "pomegranate/distributions.pyx":1717
 * 		cdef double w, logp = 0.0
 * 
 * 		with gil:             # <<<<<<<<<<<<<<
 * 			for i in range(d):
 * 				w = self.weights[i]
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            goto __pyx_L8;
          }
          __pyx_L7_error: {
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            goto __pyx_L4_error;
          }
          __pyx_L8:;
        }
    }

    /* "pomegranate/distributions.pyx":1723
 * 				logp += distribution.log_probability( symbol[i] ) + _log(w)
 * 
 * 		return logp             # <<<<<<<<<<<<<<
 * 
 * 	def sample( self ):
 */
    __pyx_r = __pyx_v_logp;
    goto __pyx_L3_return;
  }

  /* "pomegranate/distributions.pyx":1712
 * 
 * 	cdef double _mv_log_probability( self, double* symbol ) nogil:
 * 		"""Cython optimized function for log probability calculation."""             # <<<<<<<<<<<<<<
 * 
 * 		cdef int i, d = self.d
 */
  /*finally:*/ {
    __pyx_L3_return: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L0;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
  }

  /* "pomegranate/distributions.pyx":1711
 * 		return logp
 * 
 * 	cdef double _mv_log_probability( self, double* symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_WriteUnraisable("pomegranate.distributions.IndependentComponentsDistribution._mv_log_probability", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 1);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_distribution);
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1725
 * 		return logp
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Sample from the mixture. First, choose a distribution to sample from
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_5sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_33IndependentComponentsDistribution_4sample[] = "\n\t\tSample from the mixture. First, choose a distribution to sample from\n\t\taccording to the weights, then sample from that distribution. \n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_5sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_4sample(((struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_4sample(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self) {
  PyObject *__pyx_v_d = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);

  /* "pomegranate/distributions.pyx":1731
 * 		"""
 * 
 * 		return [ d.sample() for d in self.parameters[0] ]             # <<<<<<<<<<<<<<
 * 
 * 	def from_sample( self, items, weights=None, inertia=0 ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_sample); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1725
 * 		return logp
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Sample from the mixture. First, choose a distribution to sample from
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.IndependentComponentsDistribution.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_d);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1733
 * 		return [ d.sample() for d in self.parameters[0] ]
 * 
 * 	def from_sample( self, items, weights=None, inertia=0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_7from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_33IndependentComponentsDistribution_6from_sample[] = "\n\t\tSet the parameters of this Distribution to maximize the likelihood of \n\t\tthe given sample. Items holds some sort of sequence. If weights is \n\t\tspecified, it holds a sequence of value to weight each item by.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_7from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,&__pyx_n_s_inertia,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1733; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_inertia = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_sample", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1733; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.IndependentComponentsDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_6from_sample(((struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights, __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_6from_sample(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_sample", 0);

  /* "pomegranate/distributions.pyx":1740
 * 		"""
 * 
 * 		if self.frozen:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_1 = (__pyx_v_self->__pyx_base.__pyx_base.frozen != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":1741
 * 
 * 		if self.frozen:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		self.summarize( items, weights )
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":1740
 * 		"""
 * 
 * 		if self.frozen:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":1743
 * 			return
 * 
 * 		self.summarize( items, weights )             # <<<<<<<<<<<<<<
 * 		self.from_summaries( inertia )
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_summarize); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_4) {
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  }
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_weights);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":1744
 * 
 * 		self.summarize( items, weights )
 * 		self.from_summaries( inertia )             # <<<<<<<<<<<<<<
 * 
 * 	def summarize( self, items, weights=None ):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_summaries); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_inertia); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_INCREF(__pyx_v_inertia);
    __Pyx_GIVEREF(__pyx_v_inertia);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_inertia);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":1733
 * 		return [ d.sample() for d in self.parameters[0] ]
 * 
 * 	def from_sample( self, items, weights=None, inertia=0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pomegranate.distributions.IndependentComponentsDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1746
 * 		self.from_summaries( inertia )
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in an array of items and reduce it down to summary statistics. For
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_9summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_33IndependentComponentsDistribution_8summarize[] = "\n\t\tTake in an array of items and reduce it down to summary statistics. For\n\t\ta multivariate distribution, this involves just passing the appropriate\n\t\tdata down to the appropriate distributions.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_9summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("summarize (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "summarize") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("summarize", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.IndependentComponentsDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_8summarize(((struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_8summarize(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights) {
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_d = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("summarize", 0);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":1753
 * 		"""
 * 
 * 		items, weights = weight_set( items, weights )             # <<<<<<<<<<<<<<
 * 		for i, d in enumerate( self.parameters[0] ):
 * 			d.summarize( items[:,i], weights=weights )
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_weight_set); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_3) {
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  }
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_weights);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_5 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __Pyx_DECREF_SET(__pyx_v_items, __pyx_t_2);
  __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1754
 * 
 * 		items, weights = weight_set( items, weights )
 * 		for i, d in enumerate( self.parameters[0] ):             # <<<<<<<<<<<<<<
 * 			d.summarize( items[:,i], weights=weights )
 * 
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_5 = __pyx_t_2; __Pyx_INCREF(__pyx_t_5); __pyx_t_4 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_7(__pyx_t_5);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
    __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "pomegranate/distributions.pyx":1755
 * 		items, weights = weight_set( items, weights )
 * 		for i, d in enumerate( self.parameters[0] ):
 * 			d.summarize( items[:,i], weights=weights )             # <<<<<<<<<<<<<<
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_summarize); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_slice__26);
    __Pyx_GIVEREF(__pyx_slice__26);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_slice__26);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_i);
    __pyx_t_8 = PyObject_GetItem(__pyx_v_items, __pyx_t_3); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_weights, __pyx_v_weights) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "pomegranate/distributions.pyx":1754
 * 
 * 		items, weights = weight_set( items, weights )
 * 		for i, d in enumerate( self.parameters[0] ):             # <<<<<<<<<<<<<<
 * 			d.summarize( items[:,i], weights=weights )
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1746
 * 		self.from_summaries( inertia )
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in an array of items and reduce it down to summary statistics. For
 */

  /* function exit code */
  __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_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pomegranate.distributions.IndependentComponentsDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_d);
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1757
 * 			d.summarize( items[:,i], weights=weights )
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 
 * 		cdef SIZE_t i, j, d = self.d
 */

static void __pyx_f_11pomegranate_13distributions_33IndependentComponentsDistribution__summarize(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self, CYTHON_UNUSED double *__pyx_v_items, CYTHON_UNUSED double *__pyx_v_weights, __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n) {
  CYTHON_UNUSED __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_i;
  CYTHON_UNUSED __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_j;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_d;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_1;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_2;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_3;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_4;

  /* "pomegranate/distributions.pyx":1759
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 * 
 * 		cdef SIZE_t i, j, d = self.d             # <<<<<<<<<<<<<<
 * 
 * 		for i in range(n):
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.d;
  __pyx_v_d = __pyx_t_1;

  /* "pomegranate/distributions.pyx":1761
 * 		cdef SIZE_t i, j, d = self.d
 * 
 * 		for i in range(n):             # <<<<<<<<<<<<<<
 * 			for j in range(d):
 * 				pass
 */
  __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;

    /* "pomegranate/distributions.pyx":1762
 * 
 * 		for i in range(n):
 * 			for j in range(d):             # <<<<<<<<<<<<<<
 * 				pass
 * 
 */
    __pyx_t_3 = __pyx_v_d;
    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_v_j = __pyx_t_4;
    }
  }

  /* "pomegranate/distributions.pyx":1757
 * 			d.summarize( items[:,i], weights=weights )
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 
 * 		cdef SIZE_t i, j, d = self.d
 */

  /* function exit code */
}

/* "pomegranate/distributions.pyx":1765
 * 				pass
 * 
 * 	def from_summaries( self, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Use the collected summary statistics in order to update the
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_11from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_33IndependentComponentsDistribution_10from_summaries[] = "\n\t\tUse the collected summary statistics in order to update the\n\t\tdistributions.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_11from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_summaries (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_inertia,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_summaries") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1765; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_inertia = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_summaries", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1765; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.IndependentComponentsDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_10from_summaries(((struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *)__pyx_v_self), __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_10from_summaries(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self, PyObject *__pyx_v_inertia) {
  PyObject *__pyx_v_d = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_summaries", 0);

  /* "pomegranate/distributions.pyx":1772
 * 
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->__pyx_base.__pyx_base.frozen == 1) != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":1773
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if self.frozen == True:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		for d in self.parameters[0]:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":1772
 * 
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if self.frozen == True:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":1775
 * 			return
 * 
 * 		for d in self.parameters[0]:             # <<<<<<<<<<<<<<
 * 			d.from_summaries( inertia=inertia )
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":1776
 * 
 * 		for d in self.parameters[0]:
 * 			d.from_summaries( inertia=inertia )             # <<<<<<<<<<<<<<
 * 
 * 	def to_json( self ):
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_from_summaries); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_inertia, __pyx_v_inertia) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "pomegranate/distributions.pyx":1775
 * 			return
 * 
 * 		for d in self.parameters[0]:             # <<<<<<<<<<<<<<
 * 			d.from_summaries( inertia=inertia )
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":1765
 * 				pass
 * 
 * 	def from_summaries( self, inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Use the collected summary statistics in order to update the
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.IndependentComponentsDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_d);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1778
 * 			d.from_summaries( inertia=inertia )
 * 
 * 	def to_json( self ):             # <<<<<<<<<<<<<<
 * 		"""Convert the distribution to JSON format."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_13to_json(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_33IndependentComponentsDistribution_12to_json[] = "Convert the distribution to JSON format.";
static PyObject *__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_13to_json(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_json (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_12to_json(((struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_33IndependentComponentsDistribution_12to_json(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *__pyx_v_self) {
  PyObject *__pyx_v_dist = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_json", 0);

  /* "pomegranate/distributions.pyx":1781
 * 		"""Convert the distribution to JSON format."""
 * 
 * 		return json.dumps( {             # <<<<<<<<<<<<<<
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_json); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dumps); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1782
 * 
 * 		return json.dumps( {
 * 								'class' : 'Distribution',             # <<<<<<<<<<<<<<
 * 								'name'  : self.name,
 * 								'parameters' : [ [ dist.to_json() for dist in self.parameters[0] ],
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_class_2, __pyx_n_s_Distribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "pomegranate/distributions.pyx":1783
 * 		return json.dumps( {
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,             # <<<<<<<<<<<<<<
 * 								'parameters' : [ [ dist.to_json() for dist in self.parameters[0] ],
 * 								                 self.parameters[1] ],
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_v_self->__pyx_base.__pyx_base.name) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "pomegranate/distributions.pyx":1784
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,
 * 								'parameters' : [ [ dist.to_json() for dist in self.parameters[0] ],             # <<<<<<<<<<<<<<
 * 								                 self.parameters[1] ],
 * 								'frozen' : self.frozen
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
    __pyx_t_4 = __pyx_t_5; __Pyx_INCREF(__pyx_t_4); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_7(__pyx_t_4);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_dist, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_dist, __pyx_n_s_to_json); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (__pyx_t_9) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else {
      __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1785
 * 								'name'  : self.name,
 * 								'parameters' : [ [ dist.to_json() for dist in self.parameters[0] ],
 * 								                 self.parameters[1] ],             # <<<<<<<<<<<<<<
 * 								'frozen' : self.frozen
 * 						   }, separators=(',', ' : ' ), indent=4 )
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1785; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1784
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,
 * 								'parameters' : [ [ dist.to_json() for dist in self.parameters[0] ],             # <<<<<<<<<<<<<<
 * 								                 self.parameters[1] ],
 * 								'frozen' : self.frozen
 */
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
  __pyx_t_3 = 0;
  __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_parameters, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1786
 * 								'parameters' : [ [ dist.to_json() for dist in self.parameters[0] ],
 * 								                 self.parameters[1] ],
 * 								'frozen' : self.frozen             # <<<<<<<<<<<<<<
 * 						   }, separators=(',', ' : ' ), indent=4 )
 * 
 */
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_self->__pyx_base.__pyx_base.frozen); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_frozen, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":1781
 * 		"""Convert the distribution to JSON format."""
 * 
 * 		return json.dumps( {             # <<<<<<<<<<<<<<
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,
 */
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1787
 * 								                 self.parameters[1] ],
 * 								'frozen' : self.frozen
 * 						   }, separators=(',', ' : ' ), indent=4 )             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_separators, __pyx_tuple__27) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_indent, __pyx_int_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "pomegranate/distributions.pyx":1781
 * 		"""Convert the distribution to JSON format."""
 * 
 * 		return json.dumps( {             # <<<<<<<<<<<<<<
 * 								'class' : 'Distribution',
 * 								'name'  : self.name,
 */
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1778
 * 			d.from_summaries( inertia=inertia )
 * 
 * 	def to_json( self ):             # <<<<<<<<<<<<<<
 * 		"""Convert the distribution to JSON format."""
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pomegranate.distributions.IndependentComponentsDistribution.to_json", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_dist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1793
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [ self.mu.tolist(), self.cov.tolist() ]
 * 		def __set__( self, parameters ):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_10parameters_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_10parameters_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_10parameters___get__(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "pomegranate/distributions.pyx":1794
 * 	property parameters:
 * 		def __get__( self ):
 * 			return [ self.mu.tolist(), self.cov.tolist() ]             # <<<<<<<<<<<<<<
 * 		def __set__( self, parameters ):
 * 			self.mu = numpy.array( parameters[0] )
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->mu), __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->cov), __pyx_n_s_tolist); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1793
 * 
 * 	property parameters:
 * 		def __get__( self ):             # <<<<<<<<<<<<<<
 * 			return [ self.mu.tolist(), self.cov.tolist() ]
 * 		def __set__( self, parameters ):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pomegranate.distributions.MultivariateGaussianDistribution.parameters.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1795
 * 		def __get__( self ):
 * 			return [ self.mu.tolist(), self.cov.tolist() ]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.mu = numpy.array( parameters[0] )
 * 			self.cov = numpy.array( parameters[1] )
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_10parameters_2__set__(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_parameters));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, PyObject *__pyx_v_parameters) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "pomegranate/distributions.pyx":1796
 * 			return [ self.mu.tolist(), self.cov.tolist() ]
 * 		def __set__( self, parameters ):
 * 			self.mu = numpy.array( parameters[0] )             # <<<<<<<<<<<<<<
 * 			self.cov = numpy.array( parameters[1] )
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_parameters, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->mu);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->mu));
  __pyx_v_self->mu = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1797
 * 		def __set__( self, parameters ):
 * 			self.mu = numpy.array( parameters[0] )
 * 			self.cov = numpy.array( parameters[1] )             # <<<<<<<<<<<<<<
 * 
 * 	def __cinit__( self, means, covariance, frozen=False ):
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_parameters, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->cov);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->cov));
  __pyx_v_self->cov = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1795
 * 		def __get__( self ):
 * 			return [ self.mu.tolist(), self.cov.tolist() ]
 * 		def __set__( self, parameters ):             # <<<<<<<<<<<<<<
 * 			self.mu = numpy.array( parameters[0] )
 * 			self.cov = numpy.array( parameters[1] )
 */

  /* function exit code */
  __pyx_r = 0;
  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);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pomegranate.distributions.MultivariateGaussianDistribution.parameters.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1799
 * 			self.cov = numpy.array( parameters[1] )
 * 
 * 	def __cinit__( self, means, covariance, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in the mean vector and the covariance matrix.
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_means = 0;
  PyObject *__pyx_v_covariance = 0;
  PyObject *__pyx_v_frozen = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_means,&__pyx_n_s_covariance,&__pyx_n_s_frozen,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_means)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_covariance)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1799; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1799; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_means = values[0];
    __pyx_v_covariance = values[1];
    __pyx_v_frozen = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1799; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.MultivariateGaussianDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution___cinit__(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self), __pyx_v_means, __pyx_v_covariance, __pyx_v_frozen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution___cinit__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, PyObject *__pyx_v_means, PyObject *__pyx_v_covariance, PyObject *__pyx_v_frozen) {
  PyObject *__pyx_v_d = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_9;
  double __pyx_t_10;
  size_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "pomegranate/distributions.pyx":1804
 * 		"""
 * 
 * 		self.name = "MultivariateGaussianDistribution"             # <<<<<<<<<<<<<<
 * 		self.frozen = frozen
 * 		self.mu = numpy.array(means, dtype=numpy.float64)
 */
  __Pyx_INCREF(__pyx_n_s_MultivariateGaussianDistribution);
  __Pyx_GIVEREF(__pyx_n_s_MultivariateGaussianDistribution);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.__pyx_base.name);
  __pyx_v_self->__pyx_base.__pyx_base.name = __pyx_n_s_MultivariateGaussianDistribution;

  /* "pomegranate/distributions.pyx":1805
 * 
 * 		self.name = "MultivariateGaussianDistribution"
 * 		self.frozen = frozen             # <<<<<<<<<<<<<<
 * 		self.mu = numpy.array(means, dtype=numpy.float64)
 * 		self.cov = numpy.array(covariance, dtype=numpy.float64)
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_frozen); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->__pyx_base.__pyx_base.frozen = __pyx_t_1;

  /* "pomegranate/distributions.pyx":1806
 * 		self.name = "MultivariateGaussianDistribution"
 * 		self.frozen = frozen
 * 		self.mu = numpy.array(means, dtype=numpy.float64)             # <<<<<<<<<<<<<<
 * 		self.cov = numpy.array(covariance, dtype=numpy.float64)
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_means);
  __Pyx_GIVEREF(__pyx_v_means);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_means);
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_float64); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_6);
  __Pyx_GOTREF(__pyx_v_self->mu);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->mu));
  __pyx_v_self->mu = ((PyArrayObject *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "pomegranate/distributions.pyx":1807
 * 		self.frozen = frozen
 * 		self.mu = numpy.array(means, dtype=numpy.float64)
 * 		self.cov = numpy.array(covariance, dtype=numpy.float64)             # <<<<<<<<<<<<<<
 * 
 * 		if self.mu.shape[0] != self.cov.shape[0]:
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_covariance);
  __Pyx_GIVEREF(__pyx_v_covariance);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_covariance);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_GOTREF(__pyx_v_self->cov);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->cov));
  __pyx_v_self->cov = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1809
 * 		self.cov = numpy.array(covariance, dtype=numpy.float64)
 * 
 * 		if self.mu.shape[0] != self.cov.shape[0]:             # <<<<<<<<<<<<<<
 * 			raise ValueError("mu shape is {} while cov shape is {}".format( self.mu.shape[0], self.cov.shape[0] ))
 * 		if self.cov.shape[0] != self.cov.shape[1]:
 */
  __pyx_t_1 = (((__pyx_v_self->mu->dimensions[0]) != (__pyx_v_self->cov->dimensions[0])) != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":1810
 * 
 * 		if self.mu.shape[0] != self.cov.shape[0]:
 * 			raise ValueError("mu shape is {} while cov shape is {}".format( self.mu.shape[0], self.cov.shape[0] ))             # <<<<<<<<<<<<<<
 * 		if self.cov.shape[0] != self.cov.shape[1]:
 * 			raise ValueError("cov is not a square matrix, dimensions are ({}, {})".format( self.cov.shape[0], self.cov.shape[1] ) )
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_mu_shape_is_while_cov_shape_is, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->mu->dimensions[0])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->cov->dimensions[0])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_7 = 1;
      }
    }
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
    __pyx_t_6 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "pomegranate/distributions.pyx":1809
 * 		self.cov = numpy.array(covariance, dtype=numpy.float64)
 * 
 * 		if self.mu.shape[0] != self.cov.shape[0]:             # <<<<<<<<<<<<<<
 * 			raise ValueError("mu shape is {} while cov shape is {}".format( self.mu.shape[0], self.cov.shape[0] ))
 * 		if self.cov.shape[0] != self.cov.shape[1]:
 */
  }

  /* "pomegranate/distributions.pyx":1811
 * 		if self.mu.shape[0] != self.cov.shape[0]:
 * 			raise ValueError("mu shape is {} while cov shape is {}".format( self.mu.shape[0], self.cov.shape[0] ))
 * 		if self.cov.shape[0] != self.cov.shape[1]:             # <<<<<<<<<<<<<<
 * 			raise ValueError("cov is not a square matrix, dimensions are ({}, {})".format( self.cov.shape[0], self.cov.shape[1] ) )
 * 
 */
  __pyx_t_1 = (((__pyx_v_self->cov->dimensions[0]) != (__pyx_v_self->cov->dimensions[1])) != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":1812
 * 			raise ValueError("mu shape is {} while cov shape is {}".format( self.mu.shape[0], self.cov.shape[0] ))
 * 		if self.cov.shape[0] != self.cov.shape[1]:
 * 			raise ValueError("cov is not a square matrix, dimensions are ({}, {})".format( self.cov.shape[0], self.cov.shape[1] ) )             # <<<<<<<<<<<<<<
 * 
 * 		d = self.mu.shape[0]
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_cov_is_not_a_square_matrix_dimen, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->cov->dimensions[0])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->cov->dimensions[1])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_7 = 1;
      }
    }
    __pyx_t_3 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_t_4);
    __pyx_t_8 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "pomegranate/distributions.pyx":1811
 * 		if self.mu.shape[0] != self.cov.shape[0]:
 * 			raise ValueError("mu shape is {} while cov shape is {}".format( self.mu.shape[0], self.cov.shape[0] ))
 * 		if self.cov.shape[0] != self.cov.shape[1]:             # <<<<<<<<<<<<<<
 * 			raise ValueError("cov is not a square matrix, dimensions are ({}, {})".format( self.cov.shape[0], self.cov.shape[1] ) )
 * 
 */
  }

  /* "pomegranate/distributions.pyx":1814
 * 			raise ValueError("cov is not a square matrix, dimensions are ({}, {})".format( self.cov.shape[0], self.cov.shape[1] ) )
 * 
 * 		d = self.mu.shape[0]             # <<<<<<<<<<<<<<
 * 		self.d = d
 * 
 */
  __pyx_t_5 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->mu->dimensions[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_d = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1815
 * 
 * 		d = self.mu.shape[0]
 * 		self.d = d             # <<<<<<<<<<<<<<
 * 
 * 		self.inv_cov_ndarray = numpy.linalg.inv( covariance ).astype( numpy.float64 )
 */
  __pyx_t_9 = __Pyx_PyInt_As_Py_intptr_t(__pyx_v_d); if (unlikely((__pyx_t_9 == (npy_intp)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->__pyx_base.d = __pyx_t_9;

  /* "pomegranate/distributions.pyx":1817
 * 		self.d = d
 * 
 * 		self.inv_cov_ndarray = numpy.linalg.inv( covariance ).astype( numpy.float64 )             # <<<<<<<<<<<<<<
 * 		self.inv_cov = <double*> (<numpy.ndarray> self.inv_cov_ndarray).data
 * 		self._mu = <double*> (<numpy.ndarray> self.mu).data
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_linalg); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_inv); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_covariance); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_INCREF(__pyx_v_covariance);
    __Pyx_GIVEREF(__pyx_v_covariance);
    PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_covariance);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_astype); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float64); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_GOTREF(__pyx_v_self->inv_cov_ndarray);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->inv_cov_ndarray));
  __pyx_v_self->inv_cov_ndarray = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1818
 * 
 * 		self.inv_cov_ndarray = numpy.linalg.inv( covariance ).astype( numpy.float64 )
 * 		self.inv_cov = <double*> (<numpy.ndarray> self.inv_cov_ndarray).data             # <<<<<<<<<<<<<<
 * 		self._mu = <double*> (<numpy.ndarray> self.mu).data
 * 		self._cov = <double*> (<numpy.ndarray> self.cov).data
 */
  __pyx_v_self->inv_cov = ((double *)__pyx_v_self->inv_cov_ndarray->data);

  /* "pomegranate/distributions.pyx":1819
 * 		self.inv_cov_ndarray = numpy.linalg.inv( covariance ).astype( numpy.float64 )
 * 		self.inv_cov = <double*> (<numpy.ndarray> self.inv_cov_ndarray).data
 * 		self._mu = <double*> (<numpy.ndarray> self.mu).data             # <<<<<<<<<<<<<<
 * 		self._cov = <double*> (<numpy.ndarray> self.cov).data
 * 		self._log_det = _log( numpy.linalg.det( covariance ) )
 */
  __pyx_v_self->_mu = ((double *)__pyx_v_self->mu->data);

  /* "pomegranate/distributions.pyx":1820
 * 		self.inv_cov = <double*> (<numpy.ndarray> self.inv_cov_ndarray).data
 * 		self._mu = <double*> (<numpy.ndarray> self.mu).data
 * 		self._cov = <double*> (<numpy.ndarray> self.cov).data             # <<<<<<<<<<<<<<
 * 		self._log_det = _log( numpy.linalg.det( covariance ) )
 * 
 */
  __pyx_v_self->_cov = ((double *)__pyx_v_self->cov->data);

  /* "pomegranate/distributions.pyx":1821
 * 		self._mu = <double*> (<numpy.ndarray> self.mu).data
 * 		self._cov = <double*> (<numpy.ndarray> self.cov).data
 * 		self._log_det = _log( numpy.linalg.det( covariance ) )             # <<<<<<<<<<<<<<
 * 
 * 		self.w_sum = 0.0
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_linalg); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_det); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_covariance); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_INCREF(__pyx_v_covariance);
    __Pyx_GIVEREF(__pyx_v_covariance);
    PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_covariance);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_self->_log_det = __pyx_f_11pomegranate_5utils__log(__pyx_t_10);

  /* "pomegranate/distributions.pyx":1823
 * 		self._log_det = _log( numpy.linalg.det( covariance ) )
 * 
 * 		self.w_sum = 0.0             # <<<<<<<<<<<<<<
 * 		self.column_sum = <double*> calloc( d, sizeof(double) )
 * 		self.pair_sum = <double*> calloc( d*d, sizeof(double) )
 */
  __pyx_v_self->w_sum = 0.0;

  /* "pomegranate/distributions.pyx":1824
 * 
 * 		self.w_sum = 0.0
 * 		self.column_sum = <double*> calloc( d, sizeof(double) )             # <<<<<<<<<<<<<<
 * 		self.pair_sum = <double*> calloc( d*d, sizeof(double) )
 * 		memset( self.column_sum, 0, d*sizeof(double) )
 */
  __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_v_d); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->column_sum = ((double *)calloc(__pyx_t_11, (sizeof(double))));

  /* "pomegranate/distributions.pyx":1825
 * 		self.w_sum = 0.0
 * 		self.column_sum = <double*> calloc( d, sizeof(double) )
 * 		self.pair_sum = <double*> calloc( d*d, sizeof(double) )             # <<<<<<<<<<<<<<
 * 		memset( self.column_sum, 0, d*sizeof(double) )
 * 		memset( self.pair_sum, 0, d*d*sizeof(double) )
 */
  __pyx_t_5 = PyNumber_Multiply(__pyx_v_d, __pyx_v_d); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_self->pair_sum = ((double *)calloc(__pyx_t_11, (sizeof(double))));

  /* "pomegranate/distributions.pyx":1826
 * 		self.column_sum = <double*> calloc( d, sizeof(double) )
 * 		self.pair_sum = <double*> calloc( d*d, sizeof(double) )
 * 		memset( self.column_sum, 0, d*sizeof(double) )             # <<<<<<<<<<<<<<
 * 		memset( self.pair_sum, 0, d*d*sizeof(double) )
 * 
 */
  __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(double))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyNumber_Multiply(__pyx_v_d, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_3); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  memset(__pyx_v_self->column_sum, 0, __pyx_t_11);

  /* "pomegranate/distributions.pyx":1827
 * 		self.pair_sum = <double*> calloc( d*d, sizeof(double) )
 * 		memset( self.column_sum, 0, d*sizeof(double) )
 * 		memset( self.pair_sum, 0, d*d*sizeof(double) )             # <<<<<<<<<<<<<<
 * 
 * 		self._mu_new = <double*> calloc( d, sizeof(double) )
 */
  __pyx_t_3 = PyNumber_Multiply(__pyx_v_d, __pyx_v_d); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(double))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = PyNumber_Multiply(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_8); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  memset(__pyx_v_self->pair_sum, 0, __pyx_t_11);

  /* "pomegranate/distributions.pyx":1829
 * 		memset( self.pair_sum, 0, d*d*sizeof(double) )
 * 
 * 		self._mu_new = <double*> calloc( d, sizeof(double) )             # <<<<<<<<<<<<<<
 * 		self._cov_new = <double*> calloc( d*d, sizeof(double) )
 * 
 */
  __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_v_d); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_mu_new = ((double *)calloc(__pyx_t_11, (sizeof(double))));

  /* "pomegranate/distributions.pyx":1830
 * 
 * 		self._mu_new = <double*> calloc( d, sizeof(double) )
 * 		self._cov_new = <double*> calloc( d*d, sizeof(double) )             # <<<<<<<<<<<<<<
 * 
 * 	def __dealloc__(self):
 */
  __pyx_t_8 = PyNumber_Multiply(__pyx_v_d, __pyx_v_d); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_8); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_self->_cov_new = ((double *)calloc(__pyx_t_11, (sizeof(double))));

  /* "pomegranate/distributions.pyx":1799
 * 			self.cov = numpy.array( parameters[1] )
 * 
 * 	def __cinit__( self, means, covariance, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in the mean vector and the covariance matrix.
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pomegranate.distributions.MultivariateGaussianDistribution.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_d);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1832
 * 		self._cov_new = <double*> calloc( d*d, sizeof(double) )
 * 
 * 	def __dealloc__(self):             # <<<<<<<<<<<<<<
 * 		free(self._mu_new)
 * 		free(self._cov_new)
 */

/* Python wrapper */
static void __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_2__dealloc__(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_2__dealloc__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "pomegranate/distributions.pyx":1833
 * 
 * 	def __dealloc__(self):
 * 		free(self._mu_new)             # <<<<<<<<<<<<<<
 * 		free(self._cov_new)
 * 		free(self.column_sum)
 */
  free(__pyx_v_self->_mu_new);

  /* "pomegranate/distributions.pyx":1834
 * 	def __dealloc__(self):
 * 		free(self._mu_new)
 * 		free(self._cov_new)             # <<<<<<<<<<<<<<
 * 		free(self.column_sum)
 * 		free(self.pair_sum)
 */
  free(__pyx_v_self->_cov_new);

  /* "pomegranate/distributions.pyx":1835
 * 		free(self._mu_new)
 * 		free(self._cov_new)
 * 		free(self.column_sum)             # <<<<<<<<<<<<<<
 * 		free(self.pair_sum)
 * 
 */
  free(__pyx_v_self->column_sum);

  /* "pomegranate/distributions.pyx":1836
 * 		free(self._cov_new)
 * 		free(self.column_sum)
 * 		free(self.pair_sum)             # <<<<<<<<<<<<<<
 * 
 * 	def log_probability( self, symbol ):
 */
  free(__pyx_v_self->pair_sum);

  /* "pomegranate/distributions.pyx":1832
 * 		self._cov_new = <double*> calloc( d*d, sizeof(double) )
 * 
 * 	def __dealloc__(self):             # <<<<<<<<<<<<<<
 * 		free(self._mu_new)
 * 		free(self._cov_new)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "pomegranate/distributions.pyx":1838
 * 		free(self.pair_sum)
 * 
 * 	def log_probability( self, symbol ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		What's the probability of a given tuple under this mixture? It's the
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_5log_probability(PyObject *__pyx_v_self, PyObject *__pyx_v_symbol); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_32MultivariateGaussianDistribution_4log_probability[] = "\n\t\tWhat's the probability of a given tuple under this mixture? It's the\n\t\tproduct of the probabilities of each symbol in the tuple under their\n\t\trespective distribution, which is the sum of the log probabilities.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_5log_probability(PyObject *__pyx_v_self, PyObject *__pyx_v_symbol) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("log_probability (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_4log_probability(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_symbol));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_4log_probability(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, PyObject *__pyx_v_symbol) {
  PyArrayObject *__pyx_v_symbol_ndarray = 0;
  double *__pyx_v_symbol_ptr;
  double __pyx_v_logp;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("log_probability", 0);

  /* "pomegranate/distributions.pyx":1845
 * 		"""
 * 
 * 		cdef numpy.ndarray symbol_ndarray = numpy.array(symbol).astype( numpy.float64 )             # <<<<<<<<<<<<<<
 * 		cdef double* symbol_ptr = <double*> symbol_ndarray.data
 * 		cdef double logp
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_symbol); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_symbol);
    __Pyx_GIVEREF(__pyx_v_symbol);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_symbol);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_astype); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_symbol_ndarray = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1846
 * 
 * 		cdef numpy.ndarray symbol_ndarray = numpy.array(symbol).astype( numpy.float64 )
 * 		cdef double* symbol_ptr = <double*> symbol_ndarray.data             # <<<<<<<<<<<<<<
 * 		cdef double logp
 * 
 */
  __pyx_v_symbol_ptr = ((double *)__pyx_v_symbol_ndarray->data);

  /* "pomegranate/distributions.pyx":1849
 * 		cdef double logp
 * 
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			logp = self._mv_log_probability( symbol_ptr )
 * 		return logp
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "pomegranate/distributions.pyx":1850
 * 
 * 		with nogil:
 * 			logp = self._mv_log_probability( symbol_ptr )             # <<<<<<<<<<<<<<
 * 		return logp
 * 
 */
        __pyx_v_logp = ((struct __pyx_vtabstruct_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._mv_log_probability(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), __pyx_v_symbol_ptr);
      }

      /* "pomegranate/distributions.pyx":1849
 * 		cdef double logp
 * 
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			logp = self._mv_log_probability( symbol_ptr )
 * 		return logp
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "pomegranate/distributions.pyx":1851
 * 		with nogil:
 * 			logp = self._mv_log_probability( symbol_ptr )
 * 		return logp             # <<<<<<<<<<<<<<
 * 
 * 	cdef double _mv_log_probability( self, double* symbol ) nogil:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_logp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1838
 * 		free(self.pair_sum)
 * 
 * 	def log_probability( self, symbol ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		What's the probability of a given tuple under this mixture? It's the
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pomegranate.distributions.MultivariateGaussianDistribution.log_probability", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_symbol_ndarray);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1853
 * 		return logp
 * 
 * 	cdef double _mv_log_probability( self, double* symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

static double __pyx_f_11pomegranate_13distributions_32MultivariateGaussianDistribution__mv_log_probability(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, double *__pyx_v_symbol) {
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_i;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_j;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_d;
  double __pyx_v_log_det;
  double __pyx_v_logp;
  double __pyx_r;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_1;
  double __pyx_t_2;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_3;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_4;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_5;

  /* "pomegranate/distributions.pyx":1856
 * 		"""Cython optimized function for log probability calculation."""
 * 
 * 		cdef SIZE_t i, j, d = self.d             # <<<<<<<<<<<<<<
 * 		cdef double log_det = self._log_det
 * 		cdef double logp = 0.0
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.d;
  __pyx_v_d = __pyx_t_1;

  /* "pomegranate/distributions.pyx":1857
 * 
 * 		cdef SIZE_t i, j, d = self.d
 * 		cdef double log_det = self._log_det             # <<<<<<<<<<<<<<
 * 		cdef double logp = 0.0
 * 
 */
  __pyx_t_2 = __pyx_v_self->_log_det;
  __pyx_v_log_det = __pyx_t_2;

  /* "pomegranate/distributions.pyx":1858
 * 		cdef SIZE_t i, j, d = self.d
 * 		cdef double log_det = self._log_det
 * 		cdef double logp = 0.0             # <<<<<<<<<<<<<<
 * 
 * 		for i in range(d):
 */
  __pyx_v_logp = 0.0;

  /* "pomegranate/distributions.pyx":1860
 * 		cdef double logp = 0.0
 * 
 * 		for i in range(d):             # <<<<<<<<<<<<<<
 * 			for j in range(d):
 * 				logp += (symbol[i] - self._mu[i]) * (symbol[j] - self._mu[j]) * self.inv_cov[i + j*d]
 */
  __pyx_t_1 = __pyx_v_d;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_1; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "pomegranate/distributions.pyx":1861
 * 
 * 		for i in range(d):
 * 			for j in range(d):             # <<<<<<<<<<<<<<
 * 				logp += (symbol[i] - self._mu[i]) * (symbol[j] - self._mu[j]) * self.inv_cov[i + j*d]
 * 
 */
    __pyx_t_4 = __pyx_v_d;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_j = __pyx_t_5;

      /* "pomegranate/distributions.pyx":1862
 * 		for i in range(d):
 * 			for j in range(d):
 * 				logp += (symbol[i] - self._mu[i]) * (symbol[j] - self._mu[j]) * self.inv_cov[i + j*d]             # <<<<<<<<<<<<<<
 * 
 * 		return -0.5 * (d * LOG_2_PI + log_det + logp)
 */
      __pyx_v_logp = (__pyx_v_logp + ((((__pyx_v_symbol[__pyx_v_i]) - (__pyx_v_self->_mu[__pyx_v_i])) * ((__pyx_v_symbol[__pyx_v_j]) - (__pyx_v_self->_mu[__pyx_v_j]))) * (__pyx_v_self->inv_cov[(__pyx_v_i + (__pyx_v_j * __pyx_v_d))])));
    }
  }

  /* "pomegranate/distributions.pyx":1864
 * 				logp += (symbol[i] - self._mu[i]) * (symbol[j] - self._mu[j]) * self.inv_cov[i + j*d]
 * 
 * 		return -0.5 * (d * LOG_2_PI + log_det + logp)             # <<<<<<<<<<<<<<
 * 
 * 	def sample( self ):
 */
  __pyx_r = (-0.5 * (((__pyx_v_d * 1.83787706641) + __pyx_v_log_det) + __pyx_v_logp));
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1853
 * 		return logp
 * 
 * 	cdef double _mv_log_probability( self, double* symbol ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Cython optimized function for log probability calculation."""
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1866
 * 		return -0.5 * (d * LOG_2_PI + log_det + logp)
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Sample from the mixture. First, choose a distribution to sample from
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_7sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_32MultivariateGaussianDistribution_6sample[] = "\n\t\tSample from the mixture. First, choose a distribution to sample from\n\t\taccording to the weights, then sample from that distribution. \n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_7sample(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sample (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_6sample(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_6sample(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sample", 0);

  /* "pomegranate/distributions.pyx":1872
 * 		"""
 * 
 * 		return numpy.random.multivariate_normal( self.parameters[0],             # <<<<<<<<<<<<<<
 * 			self.parameters[1] )
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_multivariate_normal); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1872; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":1873
 * 
 * 		return numpy.random.multivariate_normal( self.parameters[0],
 * 			self.parameters[1] )             # <<<<<<<<<<<<<<
 * 
 * 	def from_sample (self, items, weights=None, inertia=0 ):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_parameters); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_3) {
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_5);
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":1866
 * 		return -0.5 * (d * LOG_2_PI + log_det + logp)
 * 
 * 	def sample( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Sample from the mixture. First, choose a distribution to sample from
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.MultivariateGaussianDistribution.sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1875
 * 			self.parameters[1] )
 * 
 * 	def from_sample (self, items, weights=None, inertia=0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_9from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_32MultivariateGaussianDistribution_8from_sample[] = "\n\t\tSet the parameters of this Distribution to maximize the likelihood of \n\t\tthe given sample. Items holds some sort of sequence. If weights is \n\t\tspecified, it holds a sequence of value to weight each item by.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_9from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  PyObject *__pyx_v_inertia = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,&__pyx_n_s_inertia,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1875; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_inertia = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_sample", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1875; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.MultivariateGaussianDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_8from_sample(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights, __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_8from_sample(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, PyObject *__pyx_v_inertia) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_sample", 0);

  /* "pomegranate/distributions.pyx":1882
 * 		"""
 * 
 * 		if self.frozen:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_1 = (__pyx_v_self->__pyx_base.__pyx_base.frozen != 0);
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":1883
 * 
 * 		if self.frozen:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		self.summarize( items, weights )
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":1882
 * 		"""
 * 
 * 		if self.frozen:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":1885
 * 			return
 * 
 * 		self.summarize( items, weights )             # <<<<<<<<<<<<<<
 * 		self.from_summaries( inertia )
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_summarize); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_4) {
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  }
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_weights);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":1886
 * 
 * 		self.summarize( items, weights )
 * 		self.from_summaries( inertia )             # <<<<<<<<<<<<<<
 * 
 * 	def summarize( self, items, weights=None ):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_from_summaries); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_inertia); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_INCREF(__pyx_v_inertia);
    __Pyx_GIVEREF(__pyx_v_inertia);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_inertia);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":1875
 * 			self.parameters[1] )
 * 
 * 	def from_sample (self, items, weights=None, inertia=0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pomegranate.distributions.MultivariateGaussianDistribution.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1888
 * 		self.from_summaries( inertia )
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in a series of items and their weights and reduce it down to a
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_11summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_32MultivariateGaussianDistribution_10summarize[] = "\n\t\tTake in a series of items and their weights and reduce it down to a\n\t\tsummary statistic to be used in training later.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_11summarize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("summarize (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "summarize") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1888; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("summarize", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1888; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.MultivariateGaussianDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_10summarize(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self), __pyx_v_items, __pyx_v_weights);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_10summarize(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights) {
  double *__pyx_v_items_p;
  double *__pyx_v_weights_p;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("summarize", 0);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":1894
 * 		"""
 * 
 * 		items, weights = weight_set( items, weights )             # <<<<<<<<<<<<<<
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_weight_set); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_3) {
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  }
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_weights);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_5 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __Pyx_DECREF_SET(__pyx_v_items, __pyx_t_2);
  __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":1896
 * 		items, weights = weight_set( items, weights )
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data             # <<<<<<<<<<<<<<
 * 		cdef double* weights_p = <double*> (<numpy.ndarray> weights).data
 * 
 */
  __pyx_v_items_p = ((double *)((PyArrayObject *)__pyx_v_items)->data);

  /* "pomegranate/distributions.pyx":1897
 * 
 * 		cdef double* items_p = <double*> (<numpy.ndarray> items).data
 * 		cdef double* weights_p = <double*> (<numpy.ndarray> weights).data             # <<<<<<<<<<<<<<
 * 
 * 		cdef SIZE_t n = items.shape[0]
 */
  __pyx_v_weights_p = ((double *)((PyArrayObject *)__pyx_v_weights)->data);

  /* "pomegranate/distributions.pyx":1899
 * 		cdef double* weights_p = <double*> (<numpy.ndarray> weights).data
 * 
 * 		cdef SIZE_t n = items.shape[0]             # <<<<<<<<<<<<<<
 * 
 * 		with nogil:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_items, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1899; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_Py_intptr_t(__pyx_t_5); if (unlikely((__pyx_t_7 == (npy_intp)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_n = __pyx_t_7;

  /* "pomegranate/distributions.pyx":1901
 * 		cdef SIZE_t n = items.shape[0]
 * 
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			self._summarize( items_p, weights_p, n )
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "pomegranate/distributions.pyx":1902
 * 
 * 		with nogil:
 * 			self._summarize( items_p, weights_p, n )             # <<<<<<<<<<<<<<
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 */
        ((struct __pyx_vtabstruct_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._summarize(((struct __pyx_obj_11pomegranate_13distributions_Distribution *)__pyx_v_self), __pyx_v_items_p, __pyx_v_weights_p, __pyx_v_n);
      }

      /* "pomegranate/distributions.pyx":1901
 * 		cdef SIZE_t n = items.shape[0]
 * 
 * 		with nogil:             # <<<<<<<<<<<<<<
 * 			self._summarize( items_p, weights_p, n )
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L7;
        }
        __pyx_L7:;
      }
  }

  /* "pomegranate/distributions.pyx":1888
 * 		self.from_summaries( inertia )
 * 
 * 	def summarize( self, items, weights=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in a series of items and their weights and reduce it down to a
 */

  /* function exit code */
  __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_5);
  __Pyx_AddTraceback("pomegranate.distributions.MultivariateGaussianDistribution.summarize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1904
 * 			self._summarize( items_p, weights_p, n )
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Calculate sufficient statistics for a minibatch.
 * 
 */

static void __pyx_f_11pomegranate_13distributions_32MultivariateGaussianDistribution__summarize(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, double *__pyx_v_items, double *__pyx_v_weights, __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_n) {
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_i;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_j;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_k;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_d;
  double __pyx_v_w_sum;
  double *__pyx_v_column_sum;
  double *__pyx_v_pair_sum;
  __Pyx_RefNannyDeclarations
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_1;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_2;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_3;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_4;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_5;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_6;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_7;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_summarize", 0);
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif

  /* "pomegranate/distributions.pyx":1905
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 * 		"""Calculate sufficient statistics for a minibatch.             # <<<<<<<<<<<<<<
 * 
 * 		The sufficient statistics for a multivariate gaussian update is the sum of
 */
  /*try:*/ {

    /* "pomegranate/distributions.pyx":1911
 * 		"""
 * 
 * 		cdef SIZE_t i, j, k, d = self.d             # <<<<<<<<<<<<<<
 * 		cdef double w_sum = 0.0
 * 		cdef double* column_sum = <double*> calloc(d, sizeof(double))
 */
    __pyx_t_1 = __pyx_v_self->__pyx_base.d;
    __pyx_v_d = __pyx_t_1;

    /* "pomegranate/distributions.pyx":1912
 * 
 * 		cdef SIZE_t i, j, k, d = self.d
 * 		cdef double w_sum = 0.0             # <<<<<<<<<<<<<<
 * 		cdef double* column_sum = <double*> calloc(d, sizeof(double))
 * 		cdef double* pair_sum = <double*> calloc(d*d, sizeof(double))
 */
    __pyx_v_w_sum = 0.0;

    /* "pomegranate/distributions.pyx":1913
 * 		cdef SIZE_t i, j, k, d = self.d
 * 		cdef double w_sum = 0.0
 * 		cdef double* column_sum = <double*> calloc(d, sizeof(double))             # <<<<<<<<<<<<<<
 * 		cdef double* pair_sum = <double*> calloc(d*d, sizeof(double))
 * 		memset( column_sum, 0, d*sizeof(double) )
 */
    __pyx_v_column_sum = ((double *)calloc(__pyx_v_d, (sizeof(double))));

    /* "pomegranate/distributions.pyx":1914
 * 		cdef double w_sum = 0.0
 * 		cdef double* column_sum = <double*> calloc(d, sizeof(double))
 * 		cdef double* pair_sum = <double*> calloc(d*d, sizeof(double))             # <<<<<<<<<<<<<<
 * 		memset( column_sum, 0, d*sizeof(double) )
 * 		memset( pair_sum, 0, d*d*sizeof(double) )
 */
    __pyx_v_pair_sum = ((double *)calloc((__pyx_v_d * __pyx_v_d), (sizeof(double))));

    /* "pomegranate/distributions.pyx":1915
 * 		cdef double* column_sum = <double*> calloc(d, sizeof(double))
 * 		cdef double* pair_sum = <double*> calloc(d*d, sizeof(double))
 * 		memset( column_sum, 0, d*sizeof(double) )             # <<<<<<<<<<<<<<
 * 		memset( pair_sum, 0, d*d*sizeof(double) )
 * 
 */
    memset(__pyx_v_column_sum, 0, (__pyx_v_d * (sizeof(double))));

    /* "pomegranate/distributions.pyx":1916
 * 		cdef double* pair_sum = <double*> calloc(d*d, sizeof(double))
 * 		memset( column_sum, 0, d*sizeof(double) )
 * 		memset( pair_sum, 0, d*d*sizeof(double) )             # <<<<<<<<<<<<<<
 * 
 * 		for i in range(n):
 */
    memset(__pyx_v_pair_sum, 0, ((__pyx_v_d * __pyx_v_d) * (sizeof(double))));

    /* "pomegranate/distributions.pyx":1918
 * 		memset( pair_sum, 0, d*d*sizeof(double) )
 * 
 * 		for i in range(n):             # <<<<<<<<<<<<<<
 * 			w_sum += weights[i]
 * 
 */
    __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;

      /* "pomegranate/distributions.pyx":1919
 * 
 * 		for i in range(n):
 * 			w_sum += weights[i]             # <<<<<<<<<<<<<<
 * 
 * 			for j in range(d):
 */
      __pyx_v_w_sum = (__pyx_v_w_sum + (__pyx_v_weights[__pyx_v_i]));

      /* "pomegranate/distributions.pyx":1921
 * 			w_sum += weights[i]
 * 
 * 			for j in range(d):             # <<<<<<<<<<<<<<
 * 				column_sum[j] += items[i*d + j] * weights[i]
 * 
 */
      __pyx_t_3 = __pyx_v_d;
      for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
        __pyx_v_j = __pyx_t_4;

        /* "pomegranate/distributions.pyx":1922
 * 
 * 			for j in range(d):
 * 				column_sum[j] += items[i*d + j] * weights[i]             # <<<<<<<<<<<<<<
 * 
 * 				for k in range(d):
 */
        __pyx_t_5 = __pyx_v_j;
        (__pyx_v_column_sum[__pyx_t_5]) = ((__pyx_v_column_sum[__pyx_t_5]) + ((__pyx_v_items[((__pyx_v_i * __pyx_v_d) + __pyx_v_j)]) * (__pyx_v_weights[__pyx_v_i])));

        /* "pomegranate/distributions.pyx":1924
 * 				column_sum[j] += items[i*d + j] * weights[i]
 * 
 * 				for k in range(d):             # <<<<<<<<<<<<<<
 * 					pair_sum[j*d + k] += (weights[i] * items[i*d + j] *
 * 						items[i*d + k])
 */
        __pyx_t_5 = __pyx_v_d;
        for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
          __pyx_v_k = __pyx_t_6;

          /* "pomegranate/distributions.pyx":1925
 * 
 * 				for k in range(d):
 * 					pair_sum[j*d + k] += (weights[i] * items[i*d + j] *             # <<<<<<<<<<<<<<
 * 						items[i*d + k])
 * 
 */
          __pyx_t_7 = ((__pyx_v_j * __pyx_v_d) + __pyx_v_k);

          /* "pomegranate/distributions.pyx":1926
 * 				for k in range(d):
 * 					pair_sum[j*d + k] += (weights[i] * items[i*d + j] *
 * 						items[i*d + k])             # <<<<<<<<<<<<<<
 * 
 * 		with gil:
 */
          (__pyx_v_pair_sum[__pyx_t_7]) = ((__pyx_v_pair_sum[__pyx_t_7]) + (((__pyx_v_weights[__pyx_v_i]) * (__pyx_v_items[((__pyx_v_i * __pyx_v_d) + __pyx_v_j)])) * (__pyx_v_items[((__pyx_v_i * __pyx_v_d) + __pyx_v_k)])));
        }
      }
    }

    /* "pomegranate/distributions.pyx":1928
 * 						items[i*d + k])
 * 
 * 		with gil:             # <<<<<<<<<<<<<<
 * 			self.w_sum += w_sum
 * 
 */
    {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        /*try:*/ {

          /* "pomegranate/distributions.pyx":1929
 * 
 * 		with gil:
 * 			self.w_sum += w_sum             # <<<<<<<<<<<<<<
 * 
 * 			for j in range(d):
 */
          __pyx_v_self->w_sum = (__pyx_v_self->w_sum + __pyx_v_w_sum);

          /* "pomegranate/distributions.pyx":1931
 * 			self.w_sum += w_sum
 * 
 * 			for j in range(d):             # <<<<<<<<<<<<<<
 * 				self.column_sum[j] += column_sum[j]
 * 
 */
          __pyx_t_1 = __pyx_v_d;
          for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
            __pyx_v_j = __pyx_t_2;

            /* "pomegranate/distributions.pyx":1932
 * 
 * 			for j in range(d):
 * 				self.column_sum[j] += column_sum[j]             # <<<<<<<<<<<<<<
 * 
 * 				for k in range(d):
 */
            __pyx_t_3 = __pyx_v_j;
            (__pyx_v_self->column_sum[__pyx_t_3]) = ((__pyx_v_self->column_sum[__pyx_t_3]) + (__pyx_v_column_sum[__pyx_v_j]));

            /* "pomegranate/distributions.pyx":1934
 * 				self.column_sum[j] += column_sum[j]
 * 
 * 				for k in range(d):             # <<<<<<<<<<<<<<
 * 					self.pair_sum[j*d + k] += pair_sum[j*d + k]
 * 
 */
            __pyx_t_3 = __pyx_v_d;
            for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
              __pyx_v_k = __pyx_t_4;

              /* "pomegranate/distributions.pyx":1935
 * 
 * 				for k in range(d):
 * 					self.pair_sum[j*d + k] += pair_sum[j*d + k]             # <<<<<<<<<<<<<<
 * 
 * 		free(column_sum)
 */
              __pyx_t_5 = ((__pyx_v_j * __pyx_v_d) + __pyx_v_k);
              (__pyx_v_self->pair_sum[__pyx_t_5]) = ((__pyx_v_self->pair_sum[__pyx_t_5]) + (__pyx_v_pair_sum[((__pyx_v_j * __pyx_v_d) + __pyx_v_k)]));
            }
          }
        }

        /* "pomegranate/distributions.pyx":1928
 * 						items[i*d + k])
 * 
 * 		with gil:             # <<<<<<<<<<<<<<
 * 			self.w_sum += w_sum
 * 
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            PyGILState_Release(__pyx_gilstate_save);
            #endif
            goto __pyx_L14;
          }
          __pyx_L14:;
        }
    }

    /* "pomegranate/distributions.pyx":1937
 * 					self.pair_sum[j*d + k] += pair_sum[j*d + k]
 * 
 * 		free(column_sum)             # <<<<<<<<<<<<<<
 * 		free(pair_sum)
 * 
 */
    free(__pyx_v_column_sum);

    /* "pomegranate/distributions.pyx":1938
 * 
 * 		free(column_sum)
 * 		free(pair_sum)             # <<<<<<<<<<<<<<
 * 
 * 	def from_summaries( self, double inertia=0.0 ):
 */
    free(__pyx_v_pair_sum);
  }

  /* "pomegranate/distributions.pyx":1905
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 * 		"""Calculate sufficient statistics for a minibatch.             # <<<<<<<<<<<<<<
 * 
 * 		The sufficient statistics for a multivariate gaussian update is the sum of
 */
  /*finally:*/ {
    /*normal exit:*/{
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "pomegranate/distributions.pyx":1904
 * 			self._summarize( items_p, weights_p, n )
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:             # <<<<<<<<<<<<<<
 * 		"""Calculate sufficient statistics for a minibatch.
 * 
 */

  /* function exit code */
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
}

/* "pomegranate/distributions.pyx":1940
 * 		free(pair_sum)
 * 
 * 	def from_summaries( self, double inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_13from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_32MultivariateGaussianDistribution_12from_summaries[] = "\n\t\tSet the parameters of this Distribution to maximize the likelihood of \n\t\tthe given sample. Items holds some sort of sequence. If weights is \n\t\tspecified, it holds a sequence of value to weight each item by.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_13from_summaries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_inertia;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_summaries (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_inertia,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_summaries") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1940; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_inertia = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_inertia == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1940; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_inertia = ((double)0.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_summaries", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1940; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.MultivariateGaussianDistribution.from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_12from_summaries(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self), __pyx_v_inertia);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_12from_summaries(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, double __pyx_v_inertia) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("from_summaries", 0);

  /* "pomegranate/distributions.pyx":1948
 * 
 * 		# If no summaries stored or the summary is frozen, don't do anything.
 * 		if self.frozen == True or self.w_sum < 1e-7:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  __pyx_t_2 = ((__pyx_v_self->__pyx_base.__pyx_base.frozen == 1) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_self->w_sum < 1e-7) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":1949
 * 		# If no summaries stored or the summary is frozen, don't do anything.
 * 		if self.frozen == True or self.w_sum < 1e-7:
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		self._from_summaries( inertia )
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":1948
 * 
 * 		# If no summaries stored or the summary is frozen, don't do anything.
 * 		if self.frozen == True or self.w_sum < 1e-7:             # <<<<<<<<<<<<<<
 * 			return
 * 
 */
  }

  /* "pomegranate/distributions.pyx":1951
 * 			return
 * 
 * 		self._from_summaries( inertia )             # <<<<<<<<<<<<<<
 * 
 * 	cdef void _from_summaries( self, double inertia ):
 */
  ((struct __pyx_vtabstruct_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_from_summaries(__pyx_v_self, __pyx_v_inertia);

  /* "pomegranate/distributions.pyx":1940
 * 		free(pair_sum)
 * 
 * 	def from_summaries( self, double inertia=0.0 ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Set the parameters of this Distribution to maximize the likelihood of
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1953
 * 		self._from_summaries( inertia )
 * 
 * 	cdef void _from_summaries( self, double inertia ):             # <<<<<<<<<<<<<<
 * 		"""Cython optimized optimization."""
 * 
 */

static void __pyx_f_11pomegranate_13distributions_32MultivariateGaussianDistribution__from_summaries(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, double __pyx_v_inertia) {
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_d;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_i;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_j;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_v_k;
  double *__pyx_v_column_sum;
  double *__pyx_v_pair_sum;
  double *__pyx_v_u;
  __Pyx_RefNannyDeclarations
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_1;
  double *__pyx_t_2;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_3;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_4;
  __pyx_t_11pomegranate_13distributions_SIZE_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  double __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_from_summaries", 0);

  /* "pomegranate/distributions.pyx":1956
 * 		"""Cython optimized optimization."""
 * 
 * 		cdef SIZE_t d = self.d, i, j, k             # <<<<<<<<<<<<<<
 * 		cdef double* column_sum = self.column_sum
 * 		cdef double* pair_sum = self.pair_sum
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.d;
  __pyx_v_d = __pyx_t_1;

  /* "pomegranate/distributions.pyx":1957
 * 
 * 		cdef SIZE_t d = self.d, i, j, k
 * 		cdef double* column_sum = self.column_sum             # <<<<<<<<<<<<<<
 * 		cdef double* pair_sum = self.pair_sum
 * 		cdef double* u = self._mu_new
 */
  __pyx_t_2 = __pyx_v_self->column_sum;
  __pyx_v_column_sum = __pyx_t_2;

  /* "pomegranate/distributions.pyx":1958
 * 		cdef SIZE_t d = self.d, i, j, k
 * 		cdef double* column_sum = self.column_sum
 * 		cdef double* pair_sum = self.pair_sum             # <<<<<<<<<<<<<<
 * 		cdef double* u = self._mu_new
 * 
 */
  __pyx_t_2 = __pyx_v_self->pair_sum;
  __pyx_v_pair_sum = __pyx_t_2;

  /* "pomegranate/distributions.pyx":1959
 * 		cdef double* column_sum = self.column_sum
 * 		cdef double* pair_sum = self.pair_sum
 * 		cdef double* u = self._mu_new             # <<<<<<<<<<<<<<
 * 
 * 		for i in range(d):
 */
  __pyx_t_2 = __pyx_v_self->_mu_new;
  __pyx_v_u = __pyx_t_2;

  /* "pomegranate/distributions.pyx":1961
 * 		cdef double* u = self._mu_new
 * 
 * 		for i in range(d):             # <<<<<<<<<<<<<<
 * 			u[i] = self.column_sum[i] / self.w_sum
 * 			self._mu[i] = self._mu[i] * inertia + u[i] * (1-inertia)
 */
  __pyx_t_1 = __pyx_v_d;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_1; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "pomegranate/distributions.pyx":1962
 * 
 * 		for i in range(d):
 * 			u[i] = self.column_sum[i] / self.w_sum             # <<<<<<<<<<<<<<
 * 			self._mu[i] = self._mu[i] * inertia + u[i] * (1-inertia)
 * 
 */
    (__pyx_v_u[__pyx_v_i]) = ((__pyx_v_self->column_sum[__pyx_v_i]) / __pyx_v_self->w_sum);

    /* "pomegranate/distributions.pyx":1963
 * 		for i in range(d):
 * 			u[i] = self.column_sum[i] / self.w_sum
 * 			self._mu[i] = self._mu[i] * inertia + u[i] * (1-inertia)             # <<<<<<<<<<<<<<
 * 
 * 		for j in range(d):
 */
    (__pyx_v_self->_mu[__pyx_v_i]) = (((__pyx_v_self->_mu[__pyx_v_i]) * __pyx_v_inertia) + ((__pyx_v_u[__pyx_v_i]) * (1.0 - __pyx_v_inertia)));
  }

  /* "pomegranate/distributions.pyx":1965
 * 			self._mu[i] = self._mu[i] * inertia + u[i] * (1-inertia)
 * 
 * 		for j in range(d):             # <<<<<<<<<<<<<<
 * 			for k in range(d):
 * 				self._cov_new[j*d + k] = (pair_sum[j*d + k] - column_sum[j]*u[k]
 */
  __pyx_t_1 = __pyx_v_d;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_1; __pyx_t_3+=1) {
    __pyx_v_j = __pyx_t_3;

    /* "pomegranate/distributions.pyx":1966
 * 
 * 		for j in range(d):
 * 			for k in range(d):             # <<<<<<<<<<<<<<
 * 				self._cov_new[j*d + k] = (pair_sum[j*d + k] - column_sum[j]*u[k]
 * 					- column_sum[k]*u[j] + self.w_sum*u[j]*u[k]) / self.w_sum
 */
    __pyx_t_4 = __pyx_v_d;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_k = __pyx_t_5;

      /* "pomegranate/distributions.pyx":1967
 * 		for j in range(d):
 * 			for k in range(d):
 * 				self._cov_new[j*d + k] = (pair_sum[j*d + k] - column_sum[j]*u[k]             # <<<<<<<<<<<<<<
 * 					- column_sum[k]*u[j] + self.w_sum*u[j]*u[k]) / self.w_sum
 * 				self._cov[j*d + k] = self._cov[j*d + k] * inertia + self._cov_new[j*d +k] * (1-inertia)
 */
      (__pyx_v_self->_cov_new[((__pyx_v_j * __pyx_v_d) + __pyx_v_k)]) = (((((__pyx_v_pair_sum[((__pyx_v_j * __pyx_v_d) + __pyx_v_k)]) - ((__pyx_v_column_sum[__pyx_v_j]) * (__pyx_v_u[__pyx_v_k]))) - ((__pyx_v_column_sum[__pyx_v_k]) * (__pyx_v_u[__pyx_v_j]))) + ((__pyx_v_self->w_sum * (__pyx_v_u[__pyx_v_j])) * (__pyx_v_u[__pyx_v_k]))) / __pyx_v_self->w_sum);

      /* "pomegranate/distributions.pyx":1969
 * 				self._cov_new[j*d + k] = (pair_sum[j*d + k] - column_sum[j]*u[k]
 * 					- column_sum[k]*u[j] + self.w_sum*u[j]*u[k]) / self.w_sum
 * 				self._cov[j*d + k] = self._cov[j*d + k] * inertia + self._cov_new[j*d +k] * (1-inertia)             # <<<<<<<<<<<<<<
 * 
 * 		memset( column_sum, 0, d*sizeof(double) )
 */
      (__pyx_v_self->_cov[((__pyx_v_j * __pyx_v_d) + __pyx_v_k)]) = (((__pyx_v_self->_cov[((__pyx_v_j * __pyx_v_d) + __pyx_v_k)]) * __pyx_v_inertia) + ((__pyx_v_self->_cov_new[((__pyx_v_j * __pyx_v_d) + __pyx_v_k)]) * (1.0 - __pyx_v_inertia)));
    }
  }

  /* "pomegranate/distributions.pyx":1971
 * 				self._cov[j*d + k] = self._cov[j*d + k] * inertia + self._cov_new[j*d +k] * (1-inertia)
 * 
 * 		memset( column_sum, 0, d*sizeof(double) )             # <<<<<<<<<<<<<<
 * 		memset( pair_sum, 0, d*d*sizeof(double) )
 * 		self.w_sum = 0.0
 */
  memset(__pyx_v_column_sum, 0, (__pyx_v_d * (sizeof(double))));

  /* "pomegranate/distributions.pyx":1972
 * 
 * 		memset( column_sum, 0, d*sizeof(double) )
 * 		memset( pair_sum, 0, d*d*sizeof(double) )             # <<<<<<<<<<<<<<
 * 		self.w_sum = 0.0
 * 
 */
  memset(__pyx_v_pair_sum, 0, ((__pyx_v_d * __pyx_v_d) * (sizeof(double))));

  /* "pomegranate/distributions.pyx":1973
 * 		memset( column_sum, 0, d*sizeof(double) )
 * 		memset( pair_sum, 0, d*d*sizeof(double) )
 * 		self.w_sum = 0.0             # <<<<<<<<<<<<<<
 * 
 * 		self.inv_cov_ndarray = numpy.linalg.inv( self.cov ).astype( numpy.float64 )
 */
  __pyx_v_self->w_sum = 0.0;

  /* "pomegranate/distributions.pyx":1975
 * 		self.w_sum = 0.0
 * 
 * 		self.inv_cov_ndarray = numpy.linalg.inv( self.cov ).astype( numpy.float64 )             # <<<<<<<<<<<<<<
 * 		self.inv_cov = <double*> (<numpy.ndarray> self.inv_cov_ndarray).data
 * 		self._log_det = _log( numpy.linalg.det( self.cov ) )
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_linalg); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_inv); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_9) {
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, ((PyObject *)__pyx_v_self->cov)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
  } else {
    __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
    __Pyx_INCREF(((PyObject *)__pyx_v_self->cov));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->cov));
    PyTuple_SET_ITEM(__pyx_t_10, 0+1, ((PyObject *)__pyx_v_self->cov));
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_astype); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_float64); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_10); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_6);
  __Pyx_GOTREF(__pyx_v_self->inv_cov_ndarray);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->inv_cov_ndarray));
  __pyx_v_self->inv_cov_ndarray = ((PyArrayObject *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "pomegranate/distributions.pyx":1976
 * 
 * 		self.inv_cov_ndarray = numpy.linalg.inv( self.cov ).astype( numpy.float64 )
 * 		self.inv_cov = <double*> (<numpy.ndarray> self.inv_cov_ndarray).data             # <<<<<<<<<<<<<<
 * 		self._log_det = _log( numpy.linalg.det( self.cov ) )
 * 
 */
  __pyx_v_self->inv_cov = ((double *)__pyx_v_self->inv_cov_ndarray->data);

  /* "pomegranate/distributions.pyx":1977
 * 		self.inv_cov_ndarray = numpy.linalg.inv( self.cov ).astype( numpy.float64 )
 * 		self.inv_cov = <double*> (<numpy.ndarray> self.inv_cov_ndarray).data
 * 		self._log_det = _log( numpy.linalg.det( self.cov ) )             # <<<<<<<<<<<<<<
 * 
 * cdef class ConditionalProbabilityTable( MultivariateDistribution ):
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_linalg); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_det); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_9) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_8, ((PyObject *)__pyx_v_self->cov)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
    __Pyx_INCREF(((PyObject *)__pyx_v_self->cov));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->cov));
    PyTuple_SET_ITEM(__pyx_t_10, 0+1, ((PyObject *)__pyx_v_self->cov));
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_self->_log_det = __pyx_f_11pomegranate_5utils__log(__pyx_t_11);

  /* "pomegranate/distributions.pyx":1953
 * 		self._from_summaries( inertia )
 * 
 * 	cdef void _from_summaries( self, double inertia ):             # <<<<<<<<<<<<<<
 * 		"""Cython optimized optimization."""
 * 
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_WriteUnraisable("pomegranate.distributions.MultivariateGaussianDistribution._from_summaries", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "pomegranate/distributions.pxd":75
 * 
 * cdef class MultivariateGaussianDistribution( MultivariateDistribution ):
 * 	cdef public numpy.ndarray mu, cov, inv_cov_ndarray             # <<<<<<<<<<<<<<
 * 	cdef double* inv_cov
 * 	cdef double* _mu
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu___get__(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu___get__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->mu));
  __pyx_r = ((PyObject *)__pyx_v_self->mu);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu_2__set__(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu_2__set__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->mu);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->mu));
  __pyx_v_self->mu = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.MultivariateGaussianDistribution.mu.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu_4__del__(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu_4__del__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->mu);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->mu));
  __pyx_v_self->mu = ((PyArrayObject *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov___get__(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov___get__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->cov));
  __pyx_r = ((PyObject *)__pyx_v_self->cov);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov_2__set__(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov_2__set__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->cov);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->cov));
  __pyx_v_self->cov = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.MultivariateGaussianDistribution.cov.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov_4__del__(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov_4__del__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->cov);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->cov));
  __pyx_v_self->cov = ((PyArrayObject *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray___get__(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray___get__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->inv_cov_ndarray));
  __pyx_r = ((PyObject *)__pyx_v_self->inv_cov_ndarray);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray_2__set__(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray_2__set__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->inv_cov_ndarray);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->inv_cov_ndarray));
  __pyx_v_self->inv_cov_ndarray = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.MultivariateGaussianDistribution.inv_cov_ndarray.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray_4__del__(((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray_4__del__(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->inv_cov_ndarray);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->inv_cov_ndarray));
  __pyx_v_self->inv_cov_ndarray = ((PyArrayObject *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":1986
 * 	"""
 * 
 * 	def __init__( self, table, parents, keys=None, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in the distribution represented as a list of lists, where each
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_27ConditionalProbabilityTable___init__[] = "\n\t\tTake in the distribution represented as a list of lists, where each\n\t\tinner list represents a row.\n\t\t";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_11pomegranate_13distributions_27ConditionalProbabilityTable___init__;
#endif
static int __pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_table = 0;
  PyObject *__pyx_v_parents = 0;
  PyObject *__pyx_v_keys = 0;
  CYTHON_UNUSED PyObject *__pyx_v_frozen = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_table,&__pyx_n_s_parents,&__pyx_n_s_keys,&__pyx_n_s_frozen,0};
    PyObject* values[4] = {0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_table)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_parents)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1986; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_keys);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1986; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_table = values[0];
    __pyx_v_parents = values[1];
    __pyx_v_keys = values[2];
    __pyx_v_frozen = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1986; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.ConditionalProbabilityTable.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable___init__(((struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *)__pyx_v_self), __pyx_v_table, __pyx_v_parents, __pyx_v_keys, __pyx_v_frozen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable___init__(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self, PyObject *__pyx_v_table, PyObject *__pyx_v_parents, PyObject *__pyx_v_keys, CYTHON_UNUSED PyObject *__pyx_v_frozen) {
  PyObject *__pyx_v_values = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_row = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  double __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_INCREF(__pyx_v_keys);

  /* "pomegranate/distributions.pyx":1992
 * 		"""
 * 
 * 		self.summaries = []             # <<<<<<<<<<<<<<
 * 		self.name = "ConditionalProbabilityTable"
 * 		self.frozen = False
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.__pyx_base.summaries);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.__pyx_base.summaries);
  __pyx_v_self->__pyx_base.__pyx_base.summaries = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":1993
 * 
 * 		self.summaries = []
 * 		self.name = "ConditionalProbabilityTable"             # <<<<<<<<<<<<<<
 * 		self.frozen = False
 * 
 */
  __Pyx_INCREF(__pyx_n_s_ConditionalProbabilityTable);
  __Pyx_GIVEREF(__pyx_n_s_ConditionalProbabilityTable);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.__pyx_base.name);
  __pyx_v_self->__pyx_base.__pyx_base.name = __pyx_n_s_ConditionalProbabilityTable;

  /* "pomegranate/distributions.pyx":1994
 * 		self.summaries = []
 * 		self.name = "ConditionalProbabilityTable"
 * 		self.frozen = False             # <<<<<<<<<<<<<<
 * 
 * 		if keys:
 */
  __pyx_v_self->__pyx_base.__pyx_base.frozen = 0;

  /* "pomegranate/distributions.pyx":1996
 * 		self.frozen = False
 * 
 * 		if keys:             # <<<<<<<<<<<<<<
 * 			self.parameters = [ table, parents, keys ]
 * 		else:
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_keys); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {

    /* "pomegranate/distributions.pyx":1997
 * 
 * 		if keys:
 * 			self.parameters = [ table, parents, keys ]             # <<<<<<<<<<<<<<
 * 		else:
 * 			keys = []
 */
    __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_table);
    __Pyx_GIVEREF(__pyx_v_table);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_table);
    __Pyx_INCREF(__pyx_v_parents);
    __Pyx_GIVEREF(__pyx_v_parents);
    PyList_SET_ITEM(__pyx_t_1, 1, __pyx_v_parents);
    __Pyx_INCREF(__pyx_v_keys);
    __Pyx_GIVEREF(__pyx_v_keys);
    PyList_SET_ITEM(__pyx_t_1, 2, __pyx_v_keys);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->parameters);
    __Pyx_DECREF(__pyx_v_self->parameters);
    __pyx_v_self->parameters = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":1996
 * 		self.frozen = False
 * 
 * 		if keys:             # <<<<<<<<<<<<<<
 * 			self.parameters = [ table, parents, keys ]
 * 		else:
 */
    goto __pyx_L3;
  }

  /* "pomegranate/distributions.pyx":1999
 * 			self.parameters = [ table, parents, keys ]
 * 		else:
 * 			keys = []             # <<<<<<<<<<<<<<
 * 			values = numpy.zeros( len(table) )
 * 
 */
  /*else*/ {
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_keys, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":2000
 * 		else:
 * 			keys = []
 * 			values = numpy.zeros( len(table) )             # <<<<<<<<<<<<<<
 * 
 * 			for i, row in enumerate( table ):
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = PyObject_Length(__pyx_v_table); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_values = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":2002
 * 			values = numpy.zeros( len(table) )
 * 
 * 			for i, row in enumerate( table ):             # <<<<<<<<<<<<<<
 * 				keys.append( ( tuple(row[:-1]), i ) )
 * 				values[i] = _log( row[-1] )
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_1 = __pyx_int_0;
    if (likely(PyList_CheckExact(__pyx_v_table)) || PyTuple_CheckExact(__pyx_v_table)) {
      __pyx_t_4 = __pyx_v_table; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_table); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        }
      } else {
        __pyx_t_7 = __pyx_t_8(__pyx_t_4);
        if (unlikely(!__pyx_t_7)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_XDECREF_SET(__pyx_v_row, __pyx_t_7);
      __pyx_t_7 = 0;
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
      __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1);
      __pyx_t_1 = __pyx_t_7;
      __pyx_t_7 = 0;

      /* "pomegranate/distributions.pyx":2003
 * 
 * 			for i, row in enumerate( table ):
 * 				keys.append( ( tuple(row[:-1]), i ) )             # <<<<<<<<<<<<<<
 * 				values[i] = _log( row[-1] )
 * 
 */
      __pyx_t_7 = __Pyx_PyObject_GetSlice(__pyx_v_row, 0, -1, NULL, NULL, &__pyx_slice__28, 0, 1, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = PySequence_Tuple(__pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
      __Pyx_INCREF(__pyx_v_i);
      __Pyx_GIVEREF(__pyx_v_i);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_i);
      __pyx_t_3 = 0;
      __pyx_t_9 = __Pyx_PyObject_Append(__pyx_v_keys, __pyx_t_7); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "pomegranate/distributions.pyx":2004
 * 			for i, row in enumerate( table ):
 * 				keys.append( ( tuple(row[:-1]), i ) )
 * 				values[i] = _log( row[-1] )             # <<<<<<<<<<<<<<
 * 
 * 			keys = OrderedDict( keys[::-1] )
 */
      __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_row, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2004; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_7); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyFloat_FromDouble(__pyx_f_11pomegranate_5utils__log(__pyx_t_10)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(PyObject_SetItem(__pyx_v_values, __pyx_v_i, __pyx_t_7) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "pomegranate/distributions.pyx":2002
 * 			values = numpy.zeros( len(table) )
 * 
 * 			for i, row in enumerate( table ):             # <<<<<<<<<<<<<<
 * 				keys.append( ( tuple(row[:-1]), i ) )
 * 				values[i] = _log( row[-1] )
 */
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":2006
 * 				values[i] = _log( row[-1] )
 * 
 * 			keys = OrderedDict( keys[::-1] )             # <<<<<<<<<<<<<<
 * 			self.parameters = [ values, parents, keys ]
 * 
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = PyObject_GetItem(__pyx_v_keys, __pyx_slice__29); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_keys, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":2007
 * 
 * 			keys = OrderedDict( keys[::-1] )
 * 			self.parameters = [ values, parents, keys ]             # <<<<<<<<<<<<<<
 * 
 * 	def __str__( self ):
 */
    __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_values);
    __Pyx_GIVEREF(__pyx_v_values);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_values);
    __Pyx_INCREF(__pyx_v_parents);
    __Pyx_GIVEREF(__pyx_v_parents);
    PyList_SET_ITEM(__pyx_t_1, 1, __pyx_v_parents);
    __Pyx_INCREF(__pyx_v_keys);
    __Pyx_GIVEREF(__pyx_v_keys);
    PyList_SET_ITEM(__pyx_t_1, 2, __pyx_v_keys);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->parameters);
    __Pyx_DECREF(__pyx_v_self->parameters);
    __pyx_v_self->parameters = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "pomegranate/distributions.pyx":1986
 * 	"""
 * 
 * 	def __init__( self, table, parents, keys=None, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in the distribution represented as a list of lists, where each
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.ConditionalProbabilityTable.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_row);
  __Pyx_XDECREF(__pyx_v_keys);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2009
 * 			self.parameters = [ values, parents, keys ]
 * 
 * 	def __str__( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Regenerate the table.
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_3__str__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_27ConditionalProbabilityTable_2__str__[] = "\n\t\tRegenerate the table.\n\t\t";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_11pomegranate_13distributions_27ConditionalProbabilityTable_2__str__;
#endif
static PyObject *__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_3__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_2__str__(((struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_11pomegranate_13distributions_27ConditionalProbabilityTable_7__str___2generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "pomegranate/distributions.pyx":2016
 * 		values, parents, keys = self.parameters
 * 		return "\n".join(
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )             # <<<<<<<<<<<<<<
 * 							for key, idx in keys.items() )
 * 
 */

static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_7__str___genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr *)__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_1_genexpr(__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__ *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_11pomegranate_13distributions_27ConditionalProbabilityTable_7__str___2generator, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_str___locals_genexpr); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pomegranate.distributions.ConditionalProbabilityTable.__str__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_11pomegranate_13distributions_27ConditionalProbabilityTable_7__str___2generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr *__pyx_cur_scope = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  double __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L8_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "pomegranate/distributions.pyx":2017
 * 		return "\n".join(
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )
 * 							for key, idx in keys.items() )             # <<<<<<<<<<<<<<
 * 
 * 	def __len__( self ):
 */
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_keys)) { __Pyx_RaiseClosureNameError("keys"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_keys, __pyx_n_s_items); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L7_unpacking_done:;
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_key, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_idx);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_idx, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;

    /* "pomegranate/distributions.pyx":2016
 * 		values, parents, keys = self.parameters
 * 		return "\n".join(
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )             # <<<<<<<<<<<<<<
 * 							for key, idx in keys.items() )
 * 
 */
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_values)) { __Pyx_RaiseClosureNameError("values"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_1 = PyObject_GetItem(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_values, __pyx_cur_scope->__pyx_v_idx); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyFloat_FromDouble(exp(__pyx_t_9)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Add(__pyx_cur_scope->__pyx_v_key, __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(((PyObject *)(&PyString_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
    PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)(&PyString_Type)));
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyString_Join(__pyx_kp_s__30, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    __Pyx_XGIVEREF(__pyx_t_2);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_5;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L8_resume_from_yield:;
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_2);
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_5 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "pomegranate/distributions.pyx":2017
 * 		return "\n".join(
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )
 * 							for key, idx in keys.items() )             # <<<<<<<<<<<<<<
 * 
 * 	def __len__( self ):
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":2016
 * 		values, parents, keys = self.parameters
 * 		return "\n".join(
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )             # <<<<<<<<<<<<<<
 * 							for key, idx in keys.items() )
 * 
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2009
 * 			self.parameters = [ values, parents, keys ]
 * 
 * 	def __str__( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Regenerate the table.
 */

static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_2__str__(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__ *__pyx_cur_scope;
  CYTHON_UNUSED PyObject *__pyx_v_parents = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);
  __pyx_cur_scope = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__ *)__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct____str__(__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct____str__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);

  /* "pomegranate/distributions.pyx":2014
 * 		"""
 * 
 * 		values, parents, keys = self.parameters             # <<<<<<<<<<<<<<
 * 		return "\n".join(
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )
 */
  __pyx_t_1 = __pyx_v_self->parameters;
  __Pyx_INCREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
    __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_cur_scope->__pyx_v_values = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_parents = __pyx_t_3;
  __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_cur_scope->__pyx_v_keys = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2015
 * 
 * 		values, parents, keys = self.parameters
 * 		return "\n".join(             # <<<<<<<<<<<<<<
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )
 * 							for key, idx in keys.items() )
 */
  __Pyx_XDECREF(__pyx_r);

  /* "pomegranate/distributions.pyx":2016
 * 		values, parents, keys = self.parameters
 * 		return "\n".join(
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )             # <<<<<<<<<<<<<<
 * 							for key, idx in keys.items() )
 * 
 */
  __pyx_t_1 = __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_7__str___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "pomegranate/distributions.pyx":2015
 * 
 * 		values, parents, keys = self.parameters
 * 		return "\n".join(             # <<<<<<<<<<<<<<
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )
 * 							for key, idx in keys.items() )
 */
  __pyx_t_4 = __Pyx_PyString_Join(__pyx_kp_s__31, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":2009
 * 			self.parameters = [ values, parents, keys ]
 * 
 * 	def __str__( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Regenerate the table.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pomegranate.distributions.ConditionalProbabilityTable.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_parents);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2019
 * 							for key, idx in keys.items() )
 * 
 * 	def __len__( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		The length of the distribution is the number of keys.
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_5__len__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_27ConditionalProbabilityTable_4__len__[] = "\n\t\tThe length of the distribution is the number of keys.\n\t\t";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_11pomegranate_13distributions_27ConditionalProbabilityTable_4__len__;
#endif
static Py_ssize_t __pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_5__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_4__len__(((struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_4__len__(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "pomegranate/distributions.pyx":2024
 * 		"""
 * 
 * 		return len( self.keys() )             # <<<<<<<<<<<<<<
 * 
 * 	def keys( self ):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_4;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":2019
 * 							for key, idx in keys.items() )
 * 
 * 	def __len__( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		The length of the distribution is the number of keys.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.ConditionalProbabilityTable.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2026
 * 		return len( self.keys() )
 * 
 * 	def keys( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Return the keys of the probability distribution which has parents,
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_7keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_27ConditionalProbabilityTable_6keys[] = "\n\t\tReturn the keys of the probability distribution which has parents,\n\t\tthe child variable.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_7keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("keys (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_6keys(((struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_11pomegranate_13distributions_27ConditionalProbabilityTable_4keys_2generator1(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "pomegranate/distributions.pyx":2032
 * 		"""
 * 
 * 		return tuple(set(row[-1] for row in self.parameters[2].keys()))             # <<<<<<<<<<<<<<
 * 
 * 	def log_probability( self, symbol ):
 */

static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_4keys_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr *)__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_3_genexpr(__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_3_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_11pomegranate_13distributions_27ConditionalProbabilityTable_4keys_2generator1, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_keys_locals_genexpr); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pomegranate.distributions.ConditionalProbabilityTable.keys.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_11pomegranate_13distributions_27ConditionalProbabilityTable_4keys_2generator1(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr *__pyx_cur_scope = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = PySet_New(NULL); if (unlikely(!__pyx_r)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->parameters == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(PyList_GET_ITEM(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->parameters, 2), __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_row);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_row, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_row, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(PySet_Add(__pyx_r, (PyObject*)__pyx_t_1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2026
 * 		return len( self.keys() )
 * 
 * 	def keys( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Return the keys of the probability distribution which has parents,
 */

static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_6keys(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("keys", 0);
  __pyx_cur_scope = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys *)__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_2_keys(__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_2_keys, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);

  /* "pomegranate/distributions.pyx":2032
 * 		"""
 * 
 * 		return tuple(set(row[-1] for row in self.parameters[2].keys()))             # <<<<<<<<<<<<<<
 * 
 * 	def log_probability( self, symbol ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_4keys_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_Generator_Next(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PySequence_Tuple(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":2026
 * 		return len( self.keys() )
 * 
 * 	def keys( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Return the keys of the probability distribution which has parents,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pomegranate.distributions.ConditionalProbabilityTable.keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2034
 * 		return tuple(set(row[-1] for row in self.parameters[2].keys()))
 * 
 * 	def log_probability( self, symbol ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Return the log probability of a value, which is a tuple in proper
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_9log_probability(PyObject *__pyx_v_self, PyObject *__pyx_v_symbol); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_27ConditionalProbabilityTable_8log_probability[] = "\n\t\tReturn the log probability of a value, which is a tuple in proper\n\t\tordering, like the training data.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_9log_probability(PyObject *__pyx_v_self, PyObject *__pyx_v_symbol) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("log_probability (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_8log_probability(((struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *)__pyx_v_self), ((PyObject *)__pyx_v_symbol));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_8log_probability(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self, PyObject *__pyx_v_symbol) {
  PyObject *__pyx_v_values = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_v_keys = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("log_probability", 0);

  /* "pomegranate/distributions.pyx":2041
 * 
 * 		# Unpack the parameters
 * 		values, _, keys = self.parameters             # <<<<<<<<<<<<<<
 * 
 * 		# Return the array element with that identity
 */
  __pyx_t_1 = __pyx_v_self->parameters;
  __Pyx_INCREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
    __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_values = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v__ = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_keys = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2044
 * 
 * 		# Return the array element with that identity
 * 		return values[ keys[symbol] ]             # <<<<<<<<<<<<<<
 * 
 * 	def joint( self, neighbor_values=None ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetItem(__pyx_v_keys, __pyx_v_symbol); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2044; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_GetItem(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2044; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":2034
 * 		return tuple(set(row[-1] for row in self.parameters[2].keys()))
 * 
 * 	def log_probability( self, symbol ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Return the log probability of a value, which is a tuple in proper
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pomegranate.distributions.ConditionalProbabilityTable.log_probability", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF(__pyx_v_keys);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2046
 * 		return values[ keys[symbol] ]
 * 
 * 	def joint( self, neighbor_values=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		This will turn a conditional probability table into a joint
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_11joint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_27ConditionalProbabilityTable_10joint[] = "\n\t\tThis will turn a conditional probability table into a joint\n\t\tprobability table. If the data is already a joint, it will likely\n\t\tmess up the data. It does so by scaling the parameters the probabilities\n\t\tby the parent distributions.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_11joint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_neighbor_values = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("joint (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_neighbor_values,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_neighbor_values);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "joint") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2046; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_neighbor_values = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("joint", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2046; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.ConditionalProbabilityTable.joint", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_10joint(((struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *)__pyx_v_self), __pyx_v_neighbor_values);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_11pomegranate_13distributions_27ConditionalProbabilityTable_5joint_2generator2(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "pomegranate/distributions.pyx":2091
 * 
 * 		# Normalize the values
 * 		total = sum( row[-1] for row in table )             # <<<<<<<<<<<<<<
 * 		table = [ row[:-1] + (row[-1] / total,) for row in table ]
 * 
 */

static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_5joint_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr *)__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_5_genexpr(__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_5_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_11pomegranate_13distributions_27ConditionalProbabilityTable_5joint_2generator2, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_joint_locals_genexpr); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pomegranate.distributions.ConditionalProbabilityTable.joint.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_11pomegranate_13distributions_27ConditionalProbabilityTable_5joint_2generator2(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr *__pyx_cur_scope = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_table)) { __Pyx_RaiseClosureNameError("table"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_table == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_table; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_row);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_row, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_row, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2046
 * 		return values[ keys[symbol] ]
 * 
 * 	def joint( self, neighbor_values=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		This will turn a conditional probability table into a joint
 */

static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_10joint(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self, PyObject *__pyx_v_neighbor_values) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint *__pyx_cur_scope;
  PyObject *__pyx_v_values = NULL;
  PyObject *__pyx_v_parents = NULL;
  PyObject *__pyx_v_hashes = NULL;
  PyObject *__pyx_v_nv = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_parent = NULL;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_idx = NULL;
  PyObject *__pyx_v_scaled_val = NULL;
  PyObject *__pyx_v_j = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_total = NULL;
  PyObject *__pyx_v_row = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  Py_ssize_t __pyx_t_11;
  PyObject *(*__pyx_t_12)(PyObject *);
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *__pyx_t_14 = NULL;
  double __pyx_t_15;
  int __pyx_t_16;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("joint", 0);
  __pyx_cur_scope = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint *)__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_4_joint(__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_4_joint, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __Pyx_INCREF(__pyx_v_neighbor_values);

  /* "pomegranate/distributions.pyx":2055
 * 
 * 		# Unpack the parameters
 * 		values, parents, hashes = self.parameters             # <<<<<<<<<<<<<<
 * 
 * 		neighbor_values = neighbor_values or parents+[None]
 */
  __pyx_t_1 = __pyx_v_self->parameters;
  __Pyx_INCREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
    __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_values = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_parents = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_hashes = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2057
 * 		values, parents, hashes = self.parameters
 * 
 * 		neighbor_values = neighbor_values or parents+[None]             # <<<<<<<<<<<<<<
 * 		# If given a dictionary, then decode it
 * 		if isinstance( neighbor_values, dict ):
 */
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_neighbor_values); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!__pyx_t_5) {
  } else {
    __Pyx_INCREF(__pyx_v_neighbor_values);
    __pyx_t_1 = __pyx_v_neighbor_values;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyList_SET_ITEM(__pyx_t_4, 0, Py_None);
  __pyx_t_3 = PyNumber_Add(__pyx_v_parents, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_1 = __pyx_t_3;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_L3_bool_binop_done:;
  __Pyx_DECREF_SET(__pyx_v_neighbor_values, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":2059
 * 		neighbor_values = neighbor_values or parents+[None]
 * 		# If given a dictionary, then decode it
 * 		if isinstance( neighbor_values, dict ):             # <<<<<<<<<<<<<<
 * 			nv = [ None for i in xrange( len( neighbor_values)+1 ) ]
 * 
 */
  __pyx_t_5 = PyDict_Check(__pyx_v_neighbor_values); 
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (__pyx_t_6) {

    /* "pomegranate/distributions.pyx":2060
 * 		# If given a dictionary, then decode it
 * 		if isinstance( neighbor_values, dict ):
 * 			nv = [ None for i in xrange( len( neighbor_values)+1 ) ]             # <<<<<<<<<<<<<<
 * 
 * 			# Go through each parent and find the appropriate value
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_xrange); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = PyObject_Length(__pyx_v_neighbor_values); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_7 + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0;
      __pyx_t_10 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (likely(!__pyx_t_10)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_10(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
      __pyx_t_3 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)Py_None))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_nv = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":2063
 * 
 * 			# Go through each parent and find the appropriate value
 * 			for i, parent in enumerate( parents ):             # <<<<<<<<<<<<<<
 * 				nv[i] = neighbor_values.get( parent, None )
 * 
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_1 = __pyx_int_0;
    if (likely(PyList_CheckExact(__pyx_v_parents)) || PyTuple_CheckExact(__pyx_v_parents)) {
      __pyx_t_4 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0;
      __pyx_t_10 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_parents); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_10)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_10(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_parent, __pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
      __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1);
      __pyx_t_1 = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "pomegranate/distributions.pyx":2064
 * 			# Go through each parent and find the appropriate value
 * 			for i, parent in enumerate( parents ):
 * 				nv[i] = neighbor_values.get( parent, None )             # <<<<<<<<<<<<<<
 * 
 * 			if len(neighbor_values) == len(parents):
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_neighbor_values, __pyx_n_s_get); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = NULL;
      __pyx_t_11 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_11 = 1;
        }
      }
      __pyx_t_8 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_INCREF(__pyx_v_parent);
      __Pyx_GIVEREF(__pyx_v_parent);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_11, __pyx_v_parent);
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_11, Py_None);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (unlikely(PyObject_SetItem(__pyx_v_nv, __pyx_v_i, __pyx_t_3) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pomegranate/distributions.pyx":2063
 * 
 * 			# Go through each parent and find the appropriate value
 * 			for i, parent in enumerate( parents ):             # <<<<<<<<<<<<<<
 * 				nv[i] = neighbor_values.get( parent, None )
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":2066
 * 				nv[i] = neighbor_values.get( parent, None )
 * 
 * 			if len(neighbor_values) == len(parents):             # <<<<<<<<<<<<<<
 * 				# We've already gotten the value for this marginal, because it
 * 				# was encoded as a separate factor.
 */
    __pyx_t_7 = PyObject_Length(__pyx_v_neighbor_values); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = PyObject_Length(__pyx_v_parents); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = ((__pyx_t_7 == __pyx_t_11) != 0);
    if (__pyx_t_6) {
      goto __pyx_L10;
    }

    /* "pomegranate/distributions.pyx":2072
 * 			else:
 * 				# Get values for this marginal
 * 				nv[-1] = neighbor_values.get( self, None )             # <<<<<<<<<<<<<<
 * 
 * 			neighbor_values = nv
 */
    /*else*/ {
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_neighbor_values, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = NULL;
      __pyx_t_11 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_11 = 1;
        }
      }
      __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, Py_None);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(__Pyx_SetItemInt(__pyx_v_nv, -1, __pyx_t_1, long, 1, __Pyx_PyInt_From_long, 1, 1, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L10:;

    /* "pomegranate/distributions.pyx":2074
 * 				nv[-1] = neighbor_values.get( self, None )
 * 
 * 			neighbor_values = nv             # <<<<<<<<<<<<<<
 * 
 * 		# The growing table
 */
    __Pyx_INCREF(__pyx_v_nv);
    __Pyx_DECREF_SET(__pyx_v_neighbor_values, __pyx_v_nv);

    /* "pomegranate/distributions.pyx":2059
 * 		neighbor_values = neighbor_values or parents+[None]
 * 		# If given a dictionary, then decode it
 * 		if isinstance( neighbor_values, dict ):             # <<<<<<<<<<<<<<
 * 			nv = [ None for i in xrange( len( neighbor_values)+1 ) ]
 * 
 */
  }

  /* "pomegranate/distributions.pyx":2077
 * 
 * 		# The growing table
 * 		table = []             # <<<<<<<<<<<<<<
 * 
 * 		# Create the table row by row
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2077; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_table = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":2080
 * 
 * 		# Create the table row by row
 * 		for key, idx in hashes.items():             # <<<<<<<<<<<<<<
 * 
 * 			# Scale the probability by the weights on the marginals
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_hashes, __pyx_n_s_items); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_9) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_11 = 0;
    __pyx_t_10 = NULL;
  } else {
    __pyx_t_11 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_10)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_1); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_1); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_10(__pyx_t_4);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_9 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_3);
      #else
      __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_12 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_9 = __pyx_t_12(__pyx_t_8); if (unlikely(!__pyx_t_9)) goto __pyx_L13_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_9);
      index = 1; __pyx_t_3 = __pyx_t_12(__pyx_t_8); if (unlikely(!__pyx_t_3)) goto __pyx_L13_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_12 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L14_unpacking_done;
      __pyx_L13_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_12 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L14_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_9);
    __pyx_t_9 = 0;
    __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":2083
 * 
 * 			# Scale the probability by the weights on the marginals
 * 			scaled_val = values[idx]             # <<<<<<<<<<<<<<
 * 			for j, k in enumerate( key ):
 * 				if neighbor_values[j] is not None:
 */
    __pyx_t_1 = PyObject_GetItem(__pyx_v_values, __pyx_v_idx); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2083; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_scaled_val, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":2084
 * 			# Scale the probability by the weights on the marginals
 * 			scaled_val = values[idx]
 * 			for j, k in enumerate( key ):             # <<<<<<<<<<<<<<
 * 				if neighbor_values[j] is not None:
 * 					scaled_val += neighbor_values[j].log_probability( k )
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_1 = __pyx_int_0;
    if (likely(PyList_CheckExact(__pyx_v_key)) || PyTuple_CheckExact(__pyx_v_key)) {
      __pyx_t_3 = __pyx_v_key; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_key); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_13 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_13)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_13(__pyx_t_3);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_9);
      __pyx_t_9 = 0;
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_1);
      __pyx_t_9 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_1);
      __pyx_t_1 = __pyx_t_9;
      __pyx_t_9 = 0;

      /* "pomegranate/distributions.pyx":2085
 * 			scaled_val = values[idx]
 * 			for j, k in enumerate( key ):
 * 				if neighbor_values[j] is not None:             # <<<<<<<<<<<<<<
 * 					scaled_val += neighbor_values[j].log_probability( k )
 * 
 */
      __pyx_t_9 = PyObject_GetItem(__pyx_v_neighbor_values, __pyx_v_j); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2085; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_6 = (__pyx_t_9 != Py_None);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_5 = (__pyx_t_6 != 0);
      if (__pyx_t_5) {

        /* "pomegranate/distributions.pyx":2086
 * 			for j, k in enumerate( key ):
 * 				if neighbor_values[j] is not None:
 * 					scaled_val += neighbor_values[j].log_probability( k )             # <<<<<<<<<<<<<<
 * 
 * 			table.append( key + (cexp(scaled_val),) )
 */
        __pyx_t_8 = PyObject_GetItem(__pyx_v_neighbor_values, __pyx_v_j); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_log_probability); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_8)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        if (!__pyx_t_8) {
          __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_k); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
        } else {
          __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_8); __pyx_t_8 = NULL;
          __Pyx_INCREF(__pyx_v_k);
          __Pyx_GIVEREF(__pyx_v_k);
          PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_v_k);
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_14, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_scaled_val, __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF_SET(__pyx_v_scaled_val, __pyx_t_2);
        __pyx_t_2 = 0;

        /* "pomegranate/distributions.pyx":2085
 * 			scaled_val = values[idx]
 * 			for j, k in enumerate( key ):
 * 				if neighbor_values[j] is not None:             # <<<<<<<<<<<<<<
 * 					scaled_val += neighbor_values[j].log_probability( k )
 * 
 */
      }

      /* "pomegranate/distributions.pyx":2084
 * 			# Scale the probability by the weights on the marginals
 * 			scaled_val = values[idx]
 * 			for j, k in enumerate( key ):             # <<<<<<<<<<<<<<
 * 				if neighbor_values[j] is not None:
 * 					scaled_val += neighbor_values[j].log_probability( k )
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":2088
 * 					scaled_val += neighbor_values[j].log_probability( k )
 * 
 * 			table.append( key + (cexp(scaled_val),) )             # <<<<<<<<<<<<<<
 * 
 * 		# Normalize the values
 */
    __pyx_t_15 = __pyx_PyFloat_AsDouble(__pyx_v_scaled_val); if (unlikely((__pyx_t_15 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyFloat_FromDouble(exp(__pyx_t_15)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Add(__pyx_v_key, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_16 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_table, __pyx_t_1); if (unlikely(__pyx_t_16 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":2080
 * 
 * 		# Create the table row by row
 * 		for key, idx in hashes.items():             # <<<<<<<<<<<<<<
 * 
 * 			# Scale the probability by the weights on the marginals
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2091
 * 
 * 		# Normalize the values
 * 		total = sum( row[-1] for row in table )             # <<<<<<<<<<<<<<
 * 		table = [ row[:-1] + (row[-1] / total,) for row in table ]
 * 
 */
  __pyx_t_4 = __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_5joint_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_total = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2092
 * 		# Normalize the values
 * 		total = sum( row[-1] for row in table )
 * 		table = [ row[:-1] + (row[-1] / total,) for row in table ]             # <<<<<<<<<<<<<<
 * 
 * 		return JointProbabilityTable( table, parents )
 */
  __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_table; __Pyx_INCREF(__pyx_t_1); __pyx_t_11 = 0;
  for (;;) {
    if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_11); __Pyx_INCREF(__pyx_t_3); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_row, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_row, 0, -1, NULL, NULL, &__pyx_slice__32, 0, 1, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_row, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyNumber_Divide(__pyx_t_2, __pyx_v_total); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_9 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_9))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_table);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_table, ((PyObject*)__pyx_t_4));
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2094
 * 		table = [ row[:-1] + (row[-1] / total,) for row in table ]
 * 
 * 		return JointProbabilityTable( table, parents )             # <<<<<<<<<<<<<<
 * 
 * 	def marginal( self, neighbor_values=None ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_table);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_table);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_cur_scope->__pyx_v_table);
  __Pyx_INCREF(__pyx_v_parents);
  __Pyx_GIVEREF(__pyx_v_parents);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_parents);
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11pomegranate_13distributions_JointProbabilityTable), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":2046
 * 		return values[ keys[symbol] ]
 * 
 * 	def joint( self, neighbor_values=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		This will turn a conditional probability table into a joint
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("pomegranate.distributions.ConditionalProbabilityTable.joint", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XDECREF(__pyx_v_parents);
  __Pyx_XDECREF(__pyx_v_hashes);
  __Pyx_XDECREF(__pyx_v_nv);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_parent);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_idx);
  __Pyx_XDECREF(__pyx_v_scaled_val);
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_total);
  __Pyx_XDECREF(__pyx_v_row);
  __Pyx_XDECREF(__pyx_v_neighbor_values);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2096
 * 		return JointProbabilityTable( table, parents )
 * 
 * 	def marginal( self, neighbor_values=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Calculate the marginal of the CPT. This involves normalizing to turn it
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_13marginal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_27ConditionalProbabilityTable_12marginal[] = "\n\t\tCalculate the marginal of the CPT. This involves normalizing to turn it\n\t\tinto a joint probability table, and then summing over the desired\n\t\tvalue. \n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_13marginal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_neighbor_values = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("marginal (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_neighbor_values,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_neighbor_values);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "marginal") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2096; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_neighbor_values = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("marginal", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2096; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.ConditionalProbabilityTable.marginal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_12marginal(((struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *)__pyx_v_self), __pyx_v_neighbor_values);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_12marginal(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self, PyObject *__pyx_v_neighbor_values) {
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_d = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("marginal", 0);
  __Pyx_INCREF(__pyx_v_neighbor_values);

  /* "pomegranate/distributions.pyx":2104
 * 
 * 		# Convert from a dictionary to a list if necessary
 * 		if isinstance( neighbor_values, dict ):             # <<<<<<<<<<<<<<
 * 			neighbor_values = [ neighbor_values.get( d, None ) for d in self.parameters[1] ]
 * 
 */
  __pyx_t_1 = PyDict_Check(__pyx_v_neighbor_values); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pomegranate/distributions.pyx":2105
 * 		# Convert from a dictionary to a list if necessary
 * 		if isinstance( neighbor_values, dict ):
 * 			neighbor_values = [ neighbor_values.get( d, None ) for d in self.parameters[1] ]             # <<<<<<<<<<<<<<
 * 
 * 		# Get the index we're marginalizing over
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__pyx_v_self->parameters == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (likely(PyList_CheckExact(PyList_GET_ITEM(__pyx_v_self->parameters, 1))) || PyTuple_CheckExact(PyList_GET_ITEM(__pyx_v_self->parameters, 1))) {
      __pyx_t_4 = PyList_GET_ITEM(__pyx_v_self->parameters, 1); __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(PyList_GET_ITEM(__pyx_v_self->parameters, 1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        }
      } else {
        __pyx_t_7 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_7)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_neighbor_values, __pyx_n_s_get); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
          __pyx_t_10 = 1;
        }
      }
      __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_9) {
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
      }
      __Pyx_INCREF(__pyx_v_d);
      __Pyx_GIVEREF(__pyx_v_d);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_v_d);
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, Py_None);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_neighbor_values, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":2104
 * 
 * 		# Convert from a dictionary to a list if necessary
 * 		if isinstance( neighbor_values, dict ):             # <<<<<<<<<<<<<<
 * 			neighbor_values = [ neighbor_values.get( d, None ) for d in self.parameters[1] ]
 * 
 */
  }

  /* "pomegranate/distributions.pyx":2108
 * 
 * 		# Get the index we're marginalizing over
 * 		i = -1 if neighbor_values == None else neighbor_values.index( None )             # <<<<<<<<<<<<<<
 * 		return self.joint( neighbor_values ).marginal( i )
 * 
 */
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_neighbor_values, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_2) {
    __Pyx_INCREF(__pyx_int_neg_1);
    __pyx_t_3 = __pyx_int_neg_1;
  } else {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_neighbor_values, __pyx_n_s_index); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_3 = __pyx_t_7;
    __pyx_t_7 = 0;
  }
  __pyx_v_i = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":2109
 * 		# Get the index we're marginalizing over
 * 		i = -1 if neighbor_values == None else neighbor_values.index( None )
 * 		return self.joint( neighbor_values ).marginal( i )             # <<<<<<<<<<<<<<
 * 
 * 	def from_sample( self, items, weights=None, inertia=0.0, pseudocount=0. ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_joint); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_neighbor_values); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
  } else {
    __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_8); __pyx_t_8 = NULL;
    __Pyx_INCREF(__pyx_v_neighbor_values);
    __Pyx_GIVEREF(__pyx_v_neighbor_values);
    PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_neighbor_values);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_marginal); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7); __pyx_t_7 = NULL;
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_i);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":2096
 * 		return JointProbabilityTable( table, parents )
 * 
 * 	def marginal( self, neighbor_values=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Calculate the marginal of the CPT. This involves normalizing to turn it
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pomegranate.distributions.ConditionalProbabilityTable.marginal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_d);
  __Pyx_XDECREF(__pyx_v_neighbor_values);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2111
 * 		return self.joint( neighbor_values ).marginal( i )
 * 
 * 	def from_sample( self, items, weights=None, inertia=0.0, pseudocount=0. ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Update the table based on the data.
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_15from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_27ConditionalProbabilityTable_14from_sample[] = "\n\t\tUpdate the table based on the data. \n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_15from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  CYTHON_UNUSED PyObject *__pyx_v_inertia = 0;
  CYTHON_UNUSED PyObject *__pyx_v_pseudocount = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,&__pyx_n_s_inertia,&__pyx_n_s_pseudocount,0};
    PyObject* values[4] = {0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_float_0_0);
    values[3] = ((PyObject *)__pyx_float_0_);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pseudocount);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_inertia = values[2];
    __pyx_v_pseudocount = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_sample", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.ConditionalProbabilityTable.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_14from_sample(((struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *)__pyx_v_self), __pyx_v_items, __pyx_v_weights, __pyx_v_inertia, __pyx_v_pseudocount);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_14from_sample(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, CYTHON_UNUSED PyObject *__pyx_v_inertia, CYTHON_UNUSED PyObject *__pyx_v_pseudocount) {
  PyObject *__pyx_v_counts = NULL;
  PyObject *__pyx_v_marginal_counts = NULL;
  PyObject *__pyx_v_item = NULL;
  PyObject *__pyx_v_weight = NULL;
  PyObject *__pyx_v_values = NULL;
  PyObject *__pyx_v_keys = NULL;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_count = NULL;
  PyObject *__pyx_v_marginal_count = NULL;
  PyObject *__pyx_v_probability = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  Py_ssize_t __pyx_t_11;
  double __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_sample", 0);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":2117
 * 
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if len(items) == 0 or self.frozen == True:             # <<<<<<<<<<<<<<
 * 			# No sample, so just ignore it and keep our old parameters.
 * 			return
 */
  __pyx_t_2 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = ((__pyx_t_2 == 0) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = ((__pyx_v_self->__pyx_base.__pyx_base.frozen == 1) != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":2119
 * 		if len(items) == 0 or self.frozen == True:
 * 			# No sample, so just ignore it and keep our old parameters.
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		if weights is None:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":2117
 * 
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if len(items) == 0 or self.frozen == True:             # <<<<<<<<<<<<<<
 * 			# No sample, so just ignore it and keep our old parameters.
 * 			return
 */
  }

  /* "pomegranate/distributions.pyx":2121
 * 			return
 * 
 * 		if weights is None:             # <<<<<<<<<<<<<<
 * 			# Weight everything 1 if no weights specified
 * 			weights = numpy.ones( len(items), dtype=float )
 */
  __pyx_t_1 = (__pyx_v_weights == Py_None);
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (__pyx_t_3) {

    /* "pomegranate/distributions.pyx":2123
 * 		if weights is None:
 * 			# Weight everything 1 if no weights specified
 * 			weights = numpy.ones( len(items), dtype=float )             # <<<<<<<<<<<<<<
 * 		elif numpy.sum( weights ) == 0:
 * 			# Since negative weights are banned, we must have no data.
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ones); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "pomegranate/distributions.pyx":2121
 * 			return
 * 
 * 		if weights is None:             # <<<<<<<<<<<<<<
 * 			# Weight everything 1 if no weights specified
 * 			weights = numpy.ones( len(items), dtype=float )
 */
    goto __pyx_L6;
  }

  /* "pomegranate/distributions.pyx":2124
 * 			# Weight everything 1 if no weights specified
 * 			weights = numpy.ones( len(items), dtype=float )
 * 		elif numpy.sum( weights ) == 0:             # <<<<<<<<<<<<<<
 * 			# Since negative weights are banned, we must have no data.
 * 			# Don't change parameters at all.
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sum); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_weights); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_INCREF(__pyx_v_weights);
    __Pyx_GIVEREF(__pyx_v_weights);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_weights);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_t_7, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_3) {

    /* "pomegranate/distributions.pyx":2127
 * 			# Since negative weights are banned, we must have no data.
 * 			# Don't change parameters at all.
 * 			return             # <<<<<<<<<<<<<<
 * 		else:
 * 			weights = numpy.asarray(weights, dtype=float)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":2124
 * 			# Weight everything 1 if no weights specified
 * 			weights = numpy.ones( len(items), dtype=float )
 * 		elif numpy.sum( weights ) == 0:             # <<<<<<<<<<<<<<
 * 			# Since negative weights are banned, we must have no data.
 * 			# Don't change parameters at all.
 */
  }

  /* "pomegranate/distributions.pyx":2129
 * 			return
 * 		else:
 * 			weights = numpy.asarray(weights, dtype=float)             # <<<<<<<<<<<<<<
 * 
 * 		counts = {}
 */
  /*else*/ {
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_asarray); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_weights);
    __Pyx_GIVEREF(__pyx_v_weights);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_weights);
    __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_4);
    __pyx_t_4 = 0;
  }
  __pyx_L6:;

  /* "pomegranate/distributions.pyx":2131
 * 			weights = numpy.asarray(weights, dtype=float)
 * 
 * 		counts = {}             # <<<<<<<<<<<<<<
 * 		marginal_counts = {}
 * 		for item, weight in zip(items, weights):
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_counts = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2132
 * 
 * 		counts = {}
 * 		marginal_counts = {}             # <<<<<<<<<<<<<<
 * 		for item, weight in zip(items, weights):
 * 			item = tuple(item)
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_marginal_counts = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2133
 * 		counts = {}
 * 		marginal_counts = {}
 * 		for item, weight in zip(items, weights):             # <<<<<<<<<<<<<<
 * 			item = tuple(item)
 * 
 */
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_weights);
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
    __pyx_t_4 = __pyx_t_5; __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_8(__pyx_t_4);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
      PyObject* sequence = __pyx_t_5;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
      index = 0; __pyx_t_6 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_6)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 1; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_10 = NULL;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L10_unpacking_done;
      __pyx_L9_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_10 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L10_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_weight, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "pomegranate/distributions.pyx":2134
 * 		marginal_counts = {}
 * 		for item, weight in zip(items, weights):
 * 			item = tuple(item)             # <<<<<<<<<<<<<<
 * 
 * 			counts[item] = counts.get(item, 0) + weight
 */
    __pyx_t_5 = PySequence_Tuple(__pyx_v_item); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "pomegranate/distributions.pyx":2136
 * 			item = tuple(item)
 * 
 * 			counts[item] = counts.get(item, 0) + weight             # <<<<<<<<<<<<<<
 * 			marginal_counts[item[:-1]] = marginal_counts.get(item[:-1], 0) + weight
 * 
 */
    __pyx_t_5 = __Pyx_PyDict_GetItemDefault(__pyx_v_counts, __pyx_v_item, __pyx_int_0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = PyNumber_Add(__pyx_t_5, __pyx_v_weight); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(PyDict_SetItem(__pyx_v_counts, __pyx_v_item, __pyx_t_7) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "pomegranate/distributions.pyx":2137
 * 
 * 			counts[item] = counts.get(item, 0) + weight
 * 			marginal_counts[item[:-1]] = marginal_counts.get(item[:-1], 0) + weight             # <<<<<<<<<<<<<<
 * 
 * 		values = numpy.zeros_like(self.parameters[0])
 */
    __pyx_t_7 = __Pyx_PyObject_GetSlice(__pyx_v_item, 0, -1, NULL, NULL, &__pyx_slice__34, 0, 1, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = __Pyx_PyDict_GetItemDefault(__pyx_v_marginal_counts, __pyx_t_7, __pyx_int_0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyNumber_Add(__pyx_t_5, __pyx_v_weight); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_v_item, 0, -1, NULL, NULL, &__pyx_slice__35, 0, 1, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(PyDict_SetItem(__pyx_v_marginal_counts, __pyx_t_5, __pyx_t_7) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "pomegranate/distributions.pyx":2133
 * 		counts = {}
 * 		marginal_counts = {}
 * 		for item, weight in zip(items, weights):             # <<<<<<<<<<<<<<
 * 			item = tuple(item)
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2139
 * 			marginal_counts[item[:-1]] = marginal_counts.get(item[:-1], 0) + weight
 * 
 * 		values = numpy.zeros_like(self.parameters[0])             # <<<<<<<<<<<<<<
 * 		keys = self.parameters[2]
 * 
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_zeros_like); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(__pyx_v_self->parameters == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, PyList_GET_ITEM(__pyx_v_self->parameters, 0)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL;
    __Pyx_INCREF(PyList_GET_ITEM(__pyx_v_self->parameters, 0));
    __Pyx_GIVEREF(PyList_GET_ITEM(__pyx_v_self->parameters, 0));
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, PyList_GET_ITEM(__pyx_v_self->parameters, 0));
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_values = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2140
 * 
 * 		values = numpy.zeros_like(self.parameters[0])
 * 		keys = self.parameters[2]             # <<<<<<<<<<<<<<
 * 
 * 		for key in self.parameters[2].keys():
 */
  if (unlikely(__pyx_v_self->parameters == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyList_GET_ITEM(__pyx_v_self->parameters, 2);
  __Pyx_INCREF(__pyx_t_4);
  __pyx_v_keys = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2142
 * 		keys = self.parameters[2]
 * 
 * 		for key in self.parameters[2].keys():             # <<<<<<<<<<<<<<
 * 			count = counts.get( key, 0.0 )
 * 			marginal_count = marginal_counts.get( key[:-1], 0.0 )
 */
  if (unlikely(__pyx_v_self->parameters == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(PyList_GET_ITEM(__pyx_v_self->parameters, 2), __pyx_n_s_keys); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_6) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5); __pyx_t_2 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_8(__pyx_t_5);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":2143
 * 
 * 		for key in self.parameters[2].keys():
 * 			count = counts.get( key, 0.0 )             # <<<<<<<<<<<<<<
 * 			marginal_count = marginal_counts.get( key[:-1], 0.0 )
 * 
 */
    __pyx_t_4 = __Pyx_PyDict_GetItemDefault(__pyx_v_counts, __pyx_v_key, __pyx_float_0_0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XDECREF_SET(__pyx_v_count, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":2144
 * 		for key in self.parameters[2].keys():
 * 			count = counts.get( key, 0.0 )
 * 			marginal_count = marginal_counts.get( key[:-1], 0.0 )             # <<<<<<<<<<<<<<
 * 
 * 			probability = count / marginal_count if marginal_count > 0 else 1. / len(self)
 */
    __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_key, 0, -1, NULL, NULL, &__pyx_slice__36, 0, 1, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_PyDict_GetItemDefault(__pyx_v_marginal_counts, __pyx_t_4, __pyx_float_0_0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_marginal_count, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "pomegranate/distributions.pyx":2146
 * 			marginal_count = marginal_counts.get( key[:-1], 0.0 )
 * 
 * 			probability = count / marginal_count if marginal_count > 0 else 1. / len(self)             # <<<<<<<<<<<<<<
 * 			values[keys[key]] = _log(probability)
 * 
 */
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_marginal_count, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_3) {
      __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_v_count, __pyx_v_marginal_count); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __pyx_t_4;
      __pyx_t_4 = 0;
    } else {
      __pyx_t_11 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PyFloat_FromDouble((1. / __pyx_t_11)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __pyx_t_4;
      __pyx_t_4 = 0;
    }
    __Pyx_XDECREF_SET(__pyx_v_probability, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "pomegranate/distributions.pyx":2147
 * 
 * 			probability = count / marginal_count if marginal_count > 0 else 1. / len(self)
 * 			values[keys[key]] = _log(probability)             # <<<<<<<<<<<<<<
 * 
 * 		self.parameters[0] = values
 */
    __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_probability); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = PyFloat_FromDouble(__pyx_f_11pomegranate_5utils__log(__pyx_t_12)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = PyObject_GetItem(__pyx_v_keys, __pyx_v_key); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2147; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(PyObject_SetItem(__pyx_v_values, __pyx_t_4, __pyx_t_6) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "pomegranate/distributions.pyx":2142
 * 		keys = self.parameters[2]
 * 
 * 		for key in self.parameters[2].keys():             # <<<<<<<<<<<<<<
 * 			count = counts.get( key, 0.0 )
 * 			marginal_count = marginal_counts.get( key[:-1], 0.0 )
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":2149
 * 			values[keys[key]] = _log(probability)
 * 
 * 		self.parameters[0] = values             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (unlikely(__pyx_v_self->parameters == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (unlikely(__Pyx_SetItemInt(__pyx_v_self->parameters, 0, __pyx_v_values, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "pomegranate/distributions.pyx":2111
 * 		return self.joint( neighbor_values ).marginal( i )
 * 
 * 	def from_sample( self, items, weights=None, inertia=0.0, pseudocount=0. ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Update the table based on the data.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pomegranate.distributions.ConditionalProbabilityTable.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_counts);
  __Pyx_XDECREF(__pyx_v_marginal_counts);
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_XDECREF(__pyx_v_weight);
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XDECREF(__pyx_v_keys);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_count);
  __Pyx_XDECREF(__pyx_v_marginal_count);
  __Pyx_XDECREF(__pyx_v_probability);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pxd":88
 * 
 * cdef class ConditionalProbabilityTable( MultivariateDistribution ):
 * 	cdef public list parameters             # <<<<<<<<<<<<<<
 * 
 * cdef class JointProbabilityTable( MultivariateDistribution ):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters___get__(((struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->parameters);
  __pyx_r = __pyx_v_self->parameters;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters_2__set__(((struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyList_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->parameters);
  __Pyx_DECREF(__pyx_v_self->parameters);
  __pyx_v_self->parameters = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.ConditionalProbabilityTable.parameters.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters_4__del__(((struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters_4__del__(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->parameters);
  __Pyx_DECREF(__pyx_v_self->parameters);
  __pyx_v_self->parameters = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2160
 * 	"""
 * 
 * 	def __init__( self, table, neighbors, keys=None, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in the distribution represented as a list of lists, where each
 */

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_21JointProbabilityTable___init__[] = "\n\t\tTake in the distribution represented as a list of lists, where each\n\t\tinner list represents a row.\n\t\t";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_11pomegranate_13distributions_21JointProbabilityTable___init__;
#endif
static int __pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_table = 0;
  PyObject *__pyx_v_neighbors = 0;
  PyObject *__pyx_v_keys = 0;
  CYTHON_UNUSED PyObject *__pyx_v_frozen = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_table,&__pyx_n_s_neighbors,&__pyx_n_s_keys,&__pyx_n_s_frozen,0};
    PyObject* values[4] = {0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_table)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_neighbors)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2160; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_keys);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_frozen);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2160; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_table = values[0];
    __pyx_v_neighbors = values[1];
    __pyx_v_keys = values[2];
    __pyx_v_frozen = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2160; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.JointProbabilityTable.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable___init__(((struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *)__pyx_v_self), __pyx_v_table, __pyx_v_neighbors, __pyx_v_keys, __pyx_v_frozen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable___init__(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self, PyObject *__pyx_v_table, PyObject *__pyx_v_neighbors, PyObject *__pyx_v_keys, CYTHON_UNUSED PyObject *__pyx_v_frozen) {
  PyObject *__pyx_v_values = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_row = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  double __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_INCREF(__pyx_v_keys);

  /* "pomegranate/distributions.pyx":2166
 * 		"""
 * 
 * 		self.summaries = []             # <<<<<<<<<<<<<<
 * 		self.name = "JointProbabilityTable"
 * 		self.frozen = False
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.__pyx_base.summaries);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.__pyx_base.summaries);
  __pyx_v_self->__pyx_base.__pyx_base.summaries = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pomegranate/distributions.pyx":2167
 * 
 * 		self.summaries = []
 * 		self.name = "JointProbabilityTable"             # <<<<<<<<<<<<<<
 * 		self.frozen = False
 * 
 */
  __Pyx_INCREF(__pyx_n_s_JointProbabilityTable);
  __Pyx_GIVEREF(__pyx_n_s_JointProbabilityTable);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.__pyx_base.name);
  __pyx_v_self->__pyx_base.__pyx_base.name = __pyx_n_s_JointProbabilityTable;

  /* "pomegranate/distributions.pyx":2168
 * 		self.summaries = []
 * 		self.name = "JointProbabilityTable"
 * 		self.frozen = False             # <<<<<<<<<<<<<<
 * 
 * 		if keys:
 */
  __pyx_v_self->__pyx_base.__pyx_base.frozen = 0;

  /* "pomegranate/distributions.pyx":2170
 * 		self.frozen = False
 * 
 * 		if keys:             # <<<<<<<<<<<<<<
 * 			self.parameters = [ table, neighbors, keys ]
 * 		else:
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_keys); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {

    /* "pomegranate/distributions.pyx":2171
 * 
 * 		if keys:
 * 			self.parameters = [ table, neighbors, keys ]             # <<<<<<<<<<<<<<
 * 		else:
 * 			keys = []
 */
    __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_table);
    __Pyx_GIVEREF(__pyx_v_table);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_table);
    __Pyx_INCREF(__pyx_v_neighbors);
    __Pyx_GIVEREF(__pyx_v_neighbors);
    PyList_SET_ITEM(__pyx_t_1, 1, __pyx_v_neighbors);
    __Pyx_INCREF(__pyx_v_keys);
    __Pyx_GIVEREF(__pyx_v_keys);
    PyList_SET_ITEM(__pyx_t_1, 2, __pyx_v_keys);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->parameters);
    __Pyx_DECREF(__pyx_v_self->parameters);
    __pyx_v_self->parameters = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":2170
 * 		self.frozen = False
 * 
 * 		if keys:             # <<<<<<<<<<<<<<
 * 			self.parameters = [ table, neighbors, keys ]
 * 		else:
 */
    goto __pyx_L3;
  }

  /* "pomegranate/distributions.pyx":2173
 * 			self.parameters = [ table, neighbors, keys ]
 * 		else:
 * 			keys = []             # <<<<<<<<<<<<<<
 * 			values = numpy.zeros( len(table) )
 * 
 */
  /*else*/ {
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_keys, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":2174
 * 		else:
 * 			keys = []
 * 			values = numpy.zeros( len(table) )             # <<<<<<<<<<<<<<
 * 
 * 			for i, row in enumerate( table ):
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = PyObject_Length(__pyx_v_table); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_values = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":2176
 * 			values = numpy.zeros( len(table) )
 * 
 * 			for i, row in enumerate( table ):             # <<<<<<<<<<<<<<
 * 				keys.append( ( tuple(row[:-1]), i ) )
 * 				values[i] = _log( row[-1] )
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_1 = __pyx_int_0;
    if (likely(PyList_CheckExact(__pyx_v_table)) || PyTuple_CheckExact(__pyx_v_table)) {
      __pyx_t_4 = __pyx_v_table; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_table); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        }
      } else {
        __pyx_t_7 = __pyx_t_8(__pyx_t_4);
        if (unlikely(!__pyx_t_7)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_XDECREF_SET(__pyx_v_row, __pyx_t_7);
      __pyx_t_7 = 0;
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
      __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1);
      __pyx_t_1 = __pyx_t_7;
      __pyx_t_7 = 0;

      /* "pomegranate/distributions.pyx":2177
 * 
 * 			for i, row in enumerate( table ):
 * 				keys.append( ( tuple(row[:-1]), i ) )             # <<<<<<<<<<<<<<
 * 				values[i] = _log( row[-1] )
 * 
 */
      __pyx_t_7 = __Pyx_PyObject_GetSlice(__pyx_v_row, 0, -1, NULL, NULL, &__pyx_slice__37, 0, 1, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = PySequence_Tuple(__pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
      __Pyx_INCREF(__pyx_v_i);
      __Pyx_GIVEREF(__pyx_v_i);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_i);
      __pyx_t_3 = 0;
      __pyx_t_9 = __Pyx_PyObject_Append(__pyx_v_keys, __pyx_t_7); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "pomegranate/distributions.pyx":2178
 * 			for i, row in enumerate( table ):
 * 				keys.append( ( tuple(row[:-1]), i ) )
 * 				values[i] = _log( row[-1] )             # <<<<<<<<<<<<<<
 * 
 * 			keys = OrderedDict( keys[::-1] )
 */
      __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_row, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_7); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyFloat_FromDouble(__pyx_f_11pomegranate_5utils__log(__pyx_t_10)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(PyObject_SetItem(__pyx_v_values, __pyx_v_i, __pyx_t_7) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "pomegranate/distributions.pyx":2176
 * 			values = numpy.zeros( len(table) )
 * 
 * 			for i, row in enumerate( table ):             # <<<<<<<<<<<<<<
 * 				keys.append( ( tuple(row[:-1]), i ) )
 * 				values[i] = _log( row[-1] )
 */
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":2180
 * 				values[i] = _log( row[-1] )
 * 
 * 			keys = OrderedDict( keys[::-1] )             # <<<<<<<<<<<<<<
 * 			self.parameters = [ values, neighbors, keys ]
 * 
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = PyObject_GetItem(__pyx_v_keys, __pyx_slice__38); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2180; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_keys, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":2181
 * 
 * 			keys = OrderedDict( keys[::-1] )
 * 			self.parameters = [ values, neighbors, keys ]             # <<<<<<<<<<<<<<
 * 
 * 	def __str__( self ):
 */
    __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_values);
    __Pyx_GIVEREF(__pyx_v_values);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_values);
    __Pyx_INCREF(__pyx_v_neighbors);
    __Pyx_GIVEREF(__pyx_v_neighbors);
    PyList_SET_ITEM(__pyx_t_1, 1, __pyx_v_neighbors);
    __Pyx_INCREF(__pyx_v_keys);
    __Pyx_GIVEREF(__pyx_v_keys);
    PyList_SET_ITEM(__pyx_t_1, 2, __pyx_v_keys);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->parameters);
    __Pyx_DECREF(__pyx_v_self->parameters);
    __pyx_v_self->parameters = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "pomegranate/distributions.pyx":2160
 * 	"""
 * 
 * 	def __init__( self, table, neighbors, keys=None, frozen=False ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Take in the distribution represented as a list of lists, where each
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pomegranate.distributions.JointProbabilityTable.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_row);
  __Pyx_XDECREF(__pyx_v_keys);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2183
 * 			self.parameters = [ values, neighbors, keys ]
 * 
 * 	def __str__( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Regenerate the table.
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_3__str__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_21JointProbabilityTable_2__str__[] = "\n\t\tRegenerate the table.\n\t\t";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_11pomegranate_13distributions_21JointProbabilityTable_2__str__;
#endif
static PyObject *__pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_3__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_2__str__(((struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_11pomegranate_13distributions_21JointProbabilityTable_7__str___2generator3(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "pomegranate/distributions.pyx":2190
 * 		values, parents, keys = self.parameters
 * 		return "\n".join(
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )             # <<<<<<<<<<<<<<
 * 							for key, idx in keys.items() )
 * 
 */

static PyObject *__pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_7__str___genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr *)__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_7_genexpr(__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_7_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__ *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_11pomegranate_13distributions_21JointProbabilityTable_7__str___2generator3, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_str___locals_genexpr); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pomegranate.distributions.JointProbabilityTable.__str__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_11pomegranate_13distributions_21JointProbabilityTable_7__str___2generator3(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr *__pyx_cur_scope = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  double __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L8_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "pomegranate/distributions.pyx":2191
 * 		return "\n".join(
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )
 * 							for key, idx in keys.items() )             # <<<<<<<<<<<<<<
 * 
 * 	def __len__( self ):
 */
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_keys)) { __Pyx_RaiseClosureNameError("keys"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_keys, __pyx_n_s_items); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L7_unpacking_done:;
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_key, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_idx);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_idx, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;

    /* "pomegranate/distributions.pyx":2190
 * 		values, parents, keys = self.parameters
 * 		return "\n".join(
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )             # <<<<<<<<<<<<<<
 * 							for key, idx in keys.items() )
 * 
 */
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_values)) { __Pyx_RaiseClosureNameError("values"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_1 = PyObject_GetItem(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_values, __pyx_cur_scope->__pyx_v_idx); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyFloat_FromDouble(exp(__pyx_t_9)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Add(__pyx_cur_scope->__pyx_v_key, __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(((PyObject *)(&PyString_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
    PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)(&PyString_Type)));
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyString_Join(__pyx_kp_s__30, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    __Pyx_XGIVEREF(__pyx_t_2);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_5;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L8_resume_from_yield:;
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_2);
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_5 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "pomegranate/distributions.pyx":2191
 * 		return "\n".join(
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )
 * 							for key, idx in keys.items() )             # <<<<<<<<<<<<<<
 * 
 * 	def __len__( self ):
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":2190
 * 		values, parents, keys = self.parameters
 * 		return "\n".join(
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )             # <<<<<<<<<<<<<<
 * 							for key, idx in keys.items() )
 * 
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2183
 * 			self.parameters = [ values, neighbors, keys ]
 * 
 * 	def __str__( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Regenerate the table.
 */

static PyObject *__pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_2__str__(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__ *__pyx_cur_scope;
  CYTHON_UNUSED PyObject *__pyx_v_parents = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);
  __pyx_cur_scope = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__ *)__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_6___str__(__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_6___str__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);

  /* "pomegranate/distributions.pyx":2188
 * 		"""
 * 
 * 		values, parents, keys = self.parameters             # <<<<<<<<<<<<<<
 * 		return "\n".join(
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )
 */
  __pyx_t_1 = __pyx_v_self->parameters;
  __Pyx_INCREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
    __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_cur_scope->__pyx_v_values = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_parents = __pyx_t_3;
  __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_cur_scope->__pyx_v_keys = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2189
 * 
 * 		values, parents, keys = self.parameters
 * 		return "\n".join(             # <<<<<<<<<<<<<<
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )
 * 							for key, idx in keys.items() )
 */
  __Pyx_XDECREF(__pyx_r);

  /* "pomegranate/distributions.pyx":2190
 * 		values, parents, keys = self.parameters
 * 		return "\n".join(
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )             # <<<<<<<<<<<<<<
 * 							for key, idx in keys.items() )
 * 
 */
  __pyx_t_1 = __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_7__str___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "pomegranate/distributions.pyx":2189
 * 
 * 		values, parents, keys = self.parameters
 * 		return "\n".join(             # <<<<<<<<<<<<<<
 * 					"\t".join( map( str, key + (cexp( values[idx] ),) ) )
 * 							for key, idx in keys.items() )
 */
  __pyx_t_4 = __Pyx_PyString_Join(__pyx_kp_s__31, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":2183
 * 			self.parameters = [ values, neighbors, keys ]
 * 
 * 	def __str__( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Regenerate the table.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pomegranate.distributions.JointProbabilityTable.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_parents);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2193
 * 							for key, idx in keys.items() )
 * 
 * 	def __len__( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		The length of the distribution is the number of keys.
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_5__len__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_21JointProbabilityTable_4__len__[] = "\n\t\tThe length of the distribution is the number of keys.\n\t\t";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_11pomegranate_13distributions_21JointProbabilityTable_4__len__;
#endif
static Py_ssize_t __pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_5__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_4__len__(((struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_4__len__(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "pomegranate/distributions.pyx":2198
 * 		"""
 * 
 * 		return len( self.keys() )             # <<<<<<<<<<<<<<
 * 
 * 	def keys( self ):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_4;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":2193
 * 							for key, idx in keys.items() )
 * 
 * 	def __len__( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		The length of the distribution is the number of keys.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pomegranate.distributions.JointProbabilityTable.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2200
 * 		return len( self.keys() )
 * 
 * 	def keys( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Return the keys of the probability distribution which has parents,
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_7keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_21JointProbabilityTable_6keys[] = "\n\t\tReturn the keys of the probability distribution which has parents,\n\t\tthe child variable.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_7keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("keys (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_6keys(((struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_11pomegranate_13distributions_21JointProbabilityTable_4keys_2generator4(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "pomegranate/distributions.pyx":2206
 * 		"""
 * 
 * 		return tuple(set(row[-1] for row in self.parameters[2].keys()))             # <<<<<<<<<<<<<<
 * 
 * 	def log_probability( self, symbol ):
 */

static PyObject *__pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_4keys_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr *)__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_9_genexpr(__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_9_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_11pomegranate_13distributions_21JointProbabilityTable_4keys_2generator4, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_keys_locals_genexpr); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pomegranate.distributions.JointProbabilityTable.keys.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_11pomegranate_13distributions_21JointProbabilityTable_4keys_2generator4(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr *__pyx_cur_scope = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = PySet_New(NULL); if (unlikely(!__pyx_r)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->parameters == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(PyList_GET_ITEM(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->parameters, 2), __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_row);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_row, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_row, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(PySet_Add(__pyx_r, (PyObject*)__pyx_t_1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2200
 * 		return len( self.keys() )
 * 
 * 	def keys( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Return the keys of the probability distribution which has parents,
 */

static PyObject *__pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_6keys(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("keys", 0);
  __pyx_cur_scope = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys *)__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_8_keys(__pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_8_keys, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);

  /* "pomegranate/distributions.pyx":2206
 * 		"""
 * 
 * 		return tuple(set(row[-1] for row in self.parameters[2].keys()))             # <<<<<<<<<<<<<<
 * 
 * 	def log_probability( self, symbol ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_4keys_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_Generator_Next(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PySequence_Tuple(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":2200
 * 		return len( self.keys() )
 * 
 * 	def keys( self ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Return the keys of the probability distribution which has parents,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pomegranate.distributions.JointProbabilityTable.keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2208
 * 		return tuple(set(row[-1] for row in self.parameters[2].keys()))
 * 
 * 	def log_probability( self, symbol ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Return the log probability of a value, which is a tuple in proper
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_9log_probability(PyObject *__pyx_v_self, PyObject *__pyx_v_symbol); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_21JointProbabilityTable_8log_probability[] = "\n\t\tReturn the log probability of a value, which is a tuple in proper\n\t\tordering, like the training data.\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_9log_probability(PyObject *__pyx_v_self, PyObject *__pyx_v_symbol) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("log_probability (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_8log_probability(((struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *)__pyx_v_self), ((PyObject *)__pyx_v_symbol));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_8log_probability(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self, PyObject *__pyx_v_symbol) {
  PyObject *__pyx_v_values = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_v_keys = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("log_probability", 0);

  /* "pomegranate/distributions.pyx":2215
 * 
 * 		# Unpack the parameters
 * 		values, _, keys = self.parameters             # <<<<<<<<<<<<<<
 * 
 * 		# Return the array element with that identity
 */
  __pyx_t_1 = __pyx_v_self->parameters;
  __Pyx_INCREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
    __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_values = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v__ = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_keys = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2218
 * 
 * 		# Return the array element with that identity
 * 		return values[ keys[symbol] ]             # <<<<<<<<<<<<<<
 * 
 * 	def marginal( self, wrt=-1, neighbor_values=None ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetItem(__pyx_v_keys, __pyx_v_symbol); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_GetItem(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":2208
 * 		return tuple(set(row[-1] for row in self.parameters[2].keys()))
 * 
 * 	def log_probability( self, symbol ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Return the log probability of a value, which is a tuple in proper
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pomegranate.distributions.JointProbabilityTable.log_probability", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF(__pyx_v_keys);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2220
 * 		return values[ keys[symbol] ]
 * 
 * 	def marginal( self, wrt=-1, neighbor_values=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Determine the marginal of this table with respect to the index of one
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_11marginal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_21JointProbabilityTable_10marginal[] = "\n\t\tDetermine the marginal of this table with respect to the index of one\n\t\tvariable. The parents are index 0..n-1 for n parents, and the final\n\t\tvariable is either the appropriate value or -1. For example:\n\t\ttable = \n\t\tA    B    C    p(C)\n\t\t... data ...\n\t\ttable.marginal(0) gives the marginal wrt A\n\t\ttable.marginal(1) gives the marginal wrt B\n\t\ttable.marginal(2) gives the marginal wrt C\n\t\ttable.marginal(-1) gives the marginal wrt C\n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_11marginal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_wrt = 0;
  PyObject *__pyx_v_neighbor_values = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("marginal (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_wrt,&__pyx_n_s_neighbor_values,0};
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject *)__pyx_int_neg_1);
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_wrt);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_neighbor_values);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "marginal") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2220; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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;
      }
    }
    __pyx_v_wrt = values[0];
    __pyx_v_neighbor_values = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("marginal", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2220; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.JointProbabilityTable.marginal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_10marginal(((struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *)__pyx_v_self), __pyx_v_wrt, __pyx_v_neighbor_values);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_10marginal(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self, PyObject *__pyx_v_wrt, PyObject *__pyx_v_neighbor_values) {
  PyObject *__pyx_v_values = NULL;
  PyObject *__pyx_v_neighbors = NULL;
  PyObject *__pyx_v_keys = NULL;
  PyObject *__pyx_v_d = NULL;
  double __pyx_v_total;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_idx = NULL;
  PyObject *__pyx_v_logp = NULL;
  PyObject *__pyx_v_j = NULL;
  PyObject *__pyx_v_k = NULL;
  double __pyx_v_p;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *(*__pyx_t_12)(PyObject *);
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *__pyx_t_14 = NULL;
  double __pyx_t_15;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("marginal", 0);
  __Pyx_INCREF(__pyx_v_wrt);
  __Pyx_INCREF(__pyx_v_neighbor_values);

  /* "pomegranate/distributions.pyx":2235
 * 
 * 		# Unpack the parameters
 * 		values, neighbors, keys = self.parameters             # <<<<<<<<<<<<<<
 * 
 * 		# If given a dictionary, convert to a list
 */
  __pyx_t_1 = __pyx_v_self->parameters;
  __Pyx_INCREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
    __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_values = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_neighbors = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_keys = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2238
 * 
 * 		# If given a dictionary, convert to a list
 * 		if isinstance( neighbor_values, dict ):             # <<<<<<<<<<<<<<
 * 			neighbor_values = [ neighbor_values.get( d, None ) for d in neighbors ]
 * 		if isinstance( neighbor_values, list ):
 */
  __pyx_t_5 = PyDict_Check(__pyx_v_neighbor_values); 
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (__pyx_t_6) {

    /* "pomegranate/distributions.pyx":2239
 * 		# If given a dictionary, convert to a list
 * 		if isinstance( neighbor_values, dict ):
 * 			neighbor_values = [ neighbor_values.get( d, None ) for d in neighbors ]             # <<<<<<<<<<<<<<
 * 		if isinstance( neighbor_values, list ):
 * 			wrt = neighbor_values.index( None )
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (likely(PyList_CheckExact(__pyx_v_neighbors)) || PyTuple_CheckExact(__pyx_v_neighbors)) {
      __pyx_t_4 = __pyx_v_neighbors; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_neighbors); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_8(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_neighbor_values, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_10 = 1;
        }
      }
      __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_9) {
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
      }
      __Pyx_INCREF(__pyx_v_d);
      __Pyx_GIVEREF(__pyx_v_d);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_v_d);
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, Py_None);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_neighbor_values, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pomegranate/distributions.pyx":2238
 * 
 * 		# If given a dictionary, convert to a list
 * 		if isinstance( neighbor_values, dict ):             # <<<<<<<<<<<<<<
 * 			neighbor_values = [ neighbor_values.get( d, None ) for d in neighbors ]
 * 		if isinstance( neighbor_values, list ):
 */
  }

  /* "pomegranate/distributions.pyx":2240
 * 		if isinstance( neighbor_values, dict ):
 * 			neighbor_values = [ neighbor_values.get( d, None ) for d in neighbors ]
 * 		if isinstance( neighbor_values, list ):             # <<<<<<<<<<<<<<
 * 			wrt = neighbor_values.index( None )
 * 
 */
  __pyx_t_6 = PyList_Check(__pyx_v_neighbor_values); 
  __pyx_t_5 = (__pyx_t_6 != 0);
  if (__pyx_t_5) {

    /* "pomegranate/distributions.pyx":2241
 * 			neighbor_values = [ neighbor_values.get( d, None ) for d in neighbors ]
 * 		if isinstance( neighbor_values, list ):
 * 			wrt = neighbor_values.index( None )             # <<<<<<<<<<<<<<
 * 
 * 		# Determine the keys for the respective parent distribution
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_neighbor_values, __pyx_n_s_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_wrt, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":2240
 * 		if isinstance( neighbor_values, dict ):
 * 			neighbor_values = [ neighbor_values.get( d, None ) for d in neighbors ]
 * 		if isinstance( neighbor_values, list ):             # <<<<<<<<<<<<<<
 * 			wrt = neighbor_values.index( None )
 * 
 */
  }

  /* "pomegranate/distributions.pyx":2244
 * 
 * 		# Determine the keys for the respective parent distribution
 * 		d = { k: 0 for k in neighbors[wrt].keys() }             # <<<<<<<<<<<<<<
 * 		total = 0.0
 * 
 */
  { /* enter inner scope */
    PyObject *__pyx_8genexpr9__pyx_v_k = NULL;
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2244; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyObject_GetItem(__pyx_v_neighbors, __pyx_v_wrt); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2244; __pyx_clineno = __LINE__; goto __pyx_L9_error;};
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2244; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2244; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2244; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2244; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2244; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2244; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2244; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2244; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2244; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_8(__pyx_t_2);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2244; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF_SET(__pyx_8genexpr9__pyx_v_k, __pyx_t_1);
      __pyx_t_1 = 0;
      if (unlikely(PyDict_SetItem(__pyx_t_4, (PyObject*)__pyx_8genexpr9__pyx_v_k, (PyObject*)__pyx_int_0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2244; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_8genexpr9__pyx_v_k);
    goto __pyx_L12_exit_scope;
    __pyx_L9_error:;
    __Pyx_XDECREF(__pyx_8genexpr9__pyx_v_k);
    goto __pyx_L1_error;
    __pyx_L12_exit_scope:;
  } /* exit inner scope */
  __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_4);
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2245
 * 		# Determine the keys for the respective parent distribution
 * 		d = { k: 0 for k in neighbors[wrt].keys() }
 * 		total = 0.0             # <<<<<<<<<<<<<<
 * 
 * 		for key, idx in keys.items():
 */
  __pyx_v_total = 0.0;

  /* "pomegranate/distributions.pyx":2247
 * 		total = 0.0
 * 
 * 		for key, idx in keys.items():             # <<<<<<<<<<<<<<
 * 			logp = values[idx]
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_keys, __pyx_n_s_items); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_2 = __pyx_t_4; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_8(__pyx_t_2);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_11 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
      index = 0; __pyx_t_1 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_1)) goto __pyx_L15_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 1; __pyx_t_3 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_3)) goto __pyx_L15_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_12 = NULL;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L16_unpacking_done;
      __pyx_L15_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_12 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L16_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pomegranate/distributions.pyx":2248
 * 
 * 		for key, idx in keys.items():
 * 			logp = values[idx]             # <<<<<<<<<<<<<<
 * 
 * 			if neighbor_values is not None:
 */
    __pyx_t_4 = PyObject_GetItem(__pyx_v_values, __pyx_v_idx); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2248; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XDECREF_SET(__pyx_v_logp, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":2250
 * 			logp = values[idx]
 * 
 * 			if neighbor_values is not None:             # <<<<<<<<<<<<<<
 * 				for j, k in enumerate( key ):
 * 					if j == wrt:
 */
    __pyx_t_5 = (__pyx_v_neighbor_values != Py_None);
    __pyx_t_6 = (__pyx_t_5 != 0);
    if (__pyx_t_6) {

      /* "pomegranate/distributions.pyx":2251
 * 
 * 			if neighbor_values is not None:
 * 				for j, k in enumerate( key ):             # <<<<<<<<<<<<<<
 * 					if j == wrt:
 * 						continue
 */
      __Pyx_INCREF(__pyx_int_0);
      __pyx_t_4 = __pyx_int_0;
      if (likely(PyList_CheckExact(__pyx_v_key)) || PyTuple_CheckExact(__pyx_v_key)) {
        __pyx_t_3 = __pyx_v_key; __Pyx_INCREF(__pyx_t_3); __pyx_t_10 = 0;
        __pyx_t_13 = NULL;
      } else {
        __pyx_t_10 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_key); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_13 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      for (;;) {
        if (likely(!__pyx_t_13)) {
          if (likely(PyList_CheckExact(__pyx_t_3))) {
            if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_3)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #else
            __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            #endif
          } else {
            if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #else
            __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            #endif
          }
        } else {
          __pyx_t_1 = __pyx_t_13(__pyx_t_3);
          if (unlikely(!__pyx_t_1)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_1);
        __pyx_t_1 = 0;
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_4);
        __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_4, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4);
        __pyx_t_4 = __pyx_t_1;
        __pyx_t_1 = 0;

        /* "pomegranate/distributions.pyx":2252
 * 			if neighbor_values is not None:
 * 				for j, k in enumerate( key ):
 * 					if j == wrt:             # <<<<<<<<<<<<<<
 * 						continue
 * 
 */
        __pyx_t_1 = PyObject_RichCompare(__pyx_v_j, __pyx_v_wrt, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_6) {

          /* "pomegranate/distributions.pyx":2253
 * 				for j, k in enumerate( key ):
 * 					if j == wrt:
 * 						continue             # <<<<<<<<<<<<<<
 * 
 * 					logp += neighbor_values[j].log_probability( k )
 */
          goto __pyx_L18_continue;

          /* "pomegranate/distributions.pyx":2252
 * 			if neighbor_values is not None:
 * 				for j, k in enumerate( key ):
 * 					if j == wrt:             # <<<<<<<<<<<<<<
 * 						continue
 * 
 */
        }

        /* "pomegranate/distributions.pyx":2255
 * 						continue
 * 
 * 					logp += neighbor_values[j].log_probability( k )             # <<<<<<<<<<<<<<
 * 
 * 			p = cexp( logp )
 */
        __pyx_t_11 = PyObject_GetItem(__pyx_v_neighbor_values, __pyx_v_j); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_log_probability); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_11 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
          if (likely(__pyx_t_11)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_11);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_9, function);
          }
        }
        if (!__pyx_t_11) {
          __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
        } else {
          __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_11); __pyx_t_11 = NULL;
          __Pyx_INCREF(__pyx_v_k);
          __Pyx_GIVEREF(__pyx_v_k);
          PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_v_k);
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_14, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = PyNumber_InPlaceAdd(__pyx_v_logp, __pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF_SET(__pyx_v_logp, __pyx_t_9);
        __pyx_t_9 = 0;

        /* "pomegranate/distributions.pyx":2251
 * 
 * 			if neighbor_values is not None:
 * 				for j, k in enumerate( key ):             # <<<<<<<<<<<<<<
 * 					if j == wrt:
 * 						continue
 */
        __pyx_L18_continue:;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "pomegranate/distributions.pyx":2250
 * 			logp = values[idx]
 * 
 * 			if neighbor_values is not None:             # <<<<<<<<<<<<<<
 * 				for j, k in enumerate( key ):
 * 					if j == wrt:
 */
    }

    /* "pomegranate/distributions.pyx":2257
 * 					logp += neighbor_values[j].log_probability( k )
 * 
 * 			p = cexp( logp )             # <<<<<<<<<<<<<<
 * 			d[ key[wrt] ] += p
 * 			total += p
 */
    __pyx_t_15 = __pyx_PyFloat_AsDouble(__pyx_v_logp); if (unlikely((__pyx_t_15 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_p = exp(__pyx_t_15);

    /* "pomegranate/distributions.pyx":2258
 * 
 * 			p = cexp( logp )
 * 			d[ key[wrt] ] += p             # <<<<<<<<<<<<<<
 * 			total += p
 * 
 */
    __pyx_t_4 = PyObject_GetItem(__pyx_v_key, __pyx_v_wrt); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2258; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyObject_GetItem(__pyx_v_d, __pyx_t_4); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2258; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = PyFloat_FromDouble(__pyx_v_p); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (unlikely(PyObject_SetItem(__pyx_v_d, __pyx_t_4, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":2259
 * 			p = cexp( logp )
 * 			d[ key[wrt] ] += p
 * 			total += p             # <<<<<<<<<<<<<<
 * 
 * 		for key, value in d.items():
 */
    __pyx_v_total = (__pyx_v_total + __pyx_v_p);

    /* "pomegranate/distributions.pyx":2247
 * 		total = 0.0
 * 
 * 		for key, idx in keys.items():             # <<<<<<<<<<<<<<
 * 			logp = values[idx]
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":2261
 * 			total += p
 * 
 * 		for key, value in d.items():             # <<<<<<<<<<<<<<
 * 			d[key] = value / total
 * 
 */
  __pyx_t_2 = __Pyx_PyDict_Items(__pyx_v_d); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_4 = __pyx_t_2; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_8(__pyx_t_4);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_9);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_12 = Py_TYPE(__pyx_t_3)->tp_iternext;
      index = 0; __pyx_t_1 = __pyx_t_12(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L23_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 1; __pyx_t_9 = __pyx_t_12(__pyx_t_3); if (unlikely(!__pyx_t_9)) goto __pyx_L23_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_9);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_12 = NULL;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L24_unpacking_done;
      __pyx_L23_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_12 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L24_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_9);
    __pyx_t_9 = 0;

    /* "pomegranate/distributions.pyx":2262
 * 
 * 		for key, value in d.items():
 * 			d[key] = value / total             # <<<<<<<<<<<<<<
 * 
 * 		return DiscreteDistribution( d )
 */
    __pyx_t_2 = PyFloat_FromDouble(__pyx_v_total); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyNumber_Divide(__pyx_v_value, __pyx_t_2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(PyObject_SetItem(__pyx_v_d, __pyx_v_key, __pyx_t_9) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "pomegranate/distributions.pyx":2261
 * 			total += p
 * 
 * 		for key, value in d.items():             # <<<<<<<<<<<<<<
 * 			d[key] = value / total
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2264
 * 			d[key] = value / total
 * 
 * 		return DiscreteDistribution( d )             # <<<<<<<<<<<<<<
 * 
 * 	def from_sample( self, items, weights=None, inertia=0.0, pseudocount=0. ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_d);
  __Pyx_GIVEREF(__pyx_v_d);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_d);
  __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11pomegranate_13distributions_DiscreteDistribution), __pyx_t_4, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_9;
  __pyx_t_9 = 0;
  goto __pyx_L0;

  /* "pomegranate/distributions.pyx":2220
 * 		return values[ keys[symbol] ]
 * 
 * 	def marginal( self, wrt=-1, neighbor_values=None ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Determine the marginal of this table with respect to the index of one
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("pomegranate.distributions.JointProbabilityTable.marginal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XDECREF(__pyx_v_neighbors);
  __Pyx_XDECREF(__pyx_v_keys);
  __Pyx_XDECREF(__pyx_v_d);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_idx);
  __Pyx_XDECREF(__pyx_v_logp);
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_wrt);
  __Pyx_XDECREF(__pyx_v_neighbor_values);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pyx":2266
 * 		return DiscreteDistribution( d )
 * 
 * 	def from_sample( self, items, weights=None, inertia=0.0, pseudocount=0. ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Update the table based on the data.
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_13from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11pomegranate_13distributions_21JointProbabilityTable_12from_sample[] = "\n\t\tUpdate the table based on the data. \n\t\t";
static PyObject *__pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_13from_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_weights = 0;
  CYTHON_UNUSED PyObject *__pyx_v_inertia = 0;
  CYTHON_UNUSED PyObject *__pyx_v_pseudocount = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_sample (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_weights,&__pyx_n_s_inertia,&__pyx_n_s_pseudocount,0};
    PyObject* values[4] = {0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)__pyx_float_0_0);
    values[3] = ((PyObject *)__pyx_float_0_);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_weights);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_inertia);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pseudocount);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_sample") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2266; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_items = values[0];
    __pyx_v_weights = values[1];
    __pyx_v_inertia = values[2];
    __pyx_v_pseudocount = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_sample", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2266; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("pomegranate.distributions.JointProbabilityTable.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_12from_sample(((struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *)__pyx_v_self), __pyx_v_items, __pyx_v_weights, __pyx_v_inertia, __pyx_v_pseudocount);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_12from_sample(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_weights, CYTHON_UNUSED PyObject *__pyx_v_inertia, CYTHON_UNUSED PyObject *__pyx_v_pseudocount) {
  PyObject *__pyx_v_counts = NULL;
  PyObject *__pyx_v_total = NULL;
  PyObject *__pyx_v_item = NULL;
  PyObject *__pyx_v_weight = NULL;
  PyObject *__pyx_v_values = NULL;
  PyObject *__pyx_v_keys = NULL;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_count = NULL;
  PyObject *__pyx_v_probability = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  double __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_sample", 0);
  __Pyx_INCREF(__pyx_v_weights);

  /* "pomegranate/distributions.pyx":2272
 * 
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if len(items) == 0 or self.frozen == True:             # <<<<<<<<<<<<<<
 * 			# No sample, so just ignore it and keep our old parameters.
 * 			return
 */
  __pyx_t_2 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = ((__pyx_t_2 == 0) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = ((__pyx_v_self->__pyx_base.__pyx_base.frozen == 1) != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pomegranate/distributions.pyx":2274
 * 		if len(items) == 0 or self.frozen == True:
 * 			# No sample, so just ignore it and keep our old parameters.
 * 			return             # <<<<<<<<<<<<<<
 * 
 * 		if weights is None:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":2272
 * 
 * 		# If the distribution is frozen, don't bother with any calculation
 * 		if len(items) == 0 or self.frozen == True:             # <<<<<<<<<<<<<<
 * 			# No sample, so just ignore it and keep our old parameters.
 * 			return
 */
  }

  /* "pomegranate/distributions.pyx":2276
 * 			return
 * 
 * 		if weights is None:             # <<<<<<<<<<<<<<
 * 			# Weight everything 1 if no weights specified
 * 			weights = numpy.ones( len(items), dtype=float )
 */
  __pyx_t_1 = (__pyx_v_weights == Py_None);
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (__pyx_t_3) {

    /* "pomegranate/distributions.pyx":2278
 * 		if weights is None:
 * 			# Weight everything 1 if no weights specified
 * 			weights = numpy.ones( len(items), dtype=float )             # <<<<<<<<<<<<<<
 * 		elif numpy.sum( weights ) == 0:
 * 			# Since negative weights are banned, we must have no data.
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ones); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "pomegranate/distributions.pyx":2276
 * 			return
 * 
 * 		if weights is None:             # <<<<<<<<<<<<<<
 * 			# Weight everything 1 if no weights specified
 * 			weights = numpy.ones( len(items), dtype=float )
 */
    goto __pyx_L6;
  }

  /* "pomegranate/distributions.pyx":2279
 * 			# Weight everything 1 if no weights specified
 * 			weights = numpy.ones( len(items), dtype=float )
 * 		elif numpy.sum( weights ) == 0:             # <<<<<<<<<<<<<<
 * 			# Since negative weights are banned, we must have no data.
 * 			# Don't change parameters at all.
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sum); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_weights); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_INCREF(__pyx_v_weights);
    __Pyx_GIVEREF(__pyx_v_weights);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_weights);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_t_7, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_3) {

    /* "pomegranate/distributions.pyx":2282
 * 			# Since negative weights are banned, we must have no data.
 * 			# Don't change parameters at all.
 * 			return             # <<<<<<<<<<<<<<
 * 		else:
 * 			weights = numpy.asarray(weights, dtype=float)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pomegranate/distributions.pyx":2279
 * 			# Weight everything 1 if no weights specified
 * 			weights = numpy.ones( len(items), dtype=float )
 * 		elif numpy.sum( weights ) == 0:             # <<<<<<<<<<<<<<
 * 			# Since negative weights are banned, we must have no data.
 * 			# Don't change parameters at all.
 */
  }

  /* "pomegranate/distributions.pyx":2284
 * 			return
 * 		else:
 * 			weights = numpy.asarray(weights, dtype=float)             # <<<<<<<<<<<<<<
 * 
 * 		counts = {}
 */
  /*else*/ {
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_asarray); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_weights);
    __Pyx_GIVEREF(__pyx_v_weights);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_weights);
    __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_weights, __pyx_t_4);
    __pyx_t_4 = 0;
  }
  __pyx_L6:;

  /* "pomegranate/distributions.pyx":2286
 * 			weights = numpy.asarray(weights, dtype=float)
 * 
 * 		counts = {}             # <<<<<<<<<<<<<<
 * 		total = 0.0
 * 		for item, weight in zip(items, weights):
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_counts = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2287
 * 
 * 		counts = {}
 * 		total = 0.0             # <<<<<<<<<<<<<<
 * 		for item, weight in zip(items, weights):
 * 			item = tuple(item)
 */
  __Pyx_INCREF(__pyx_float_0_0);
  __pyx_v_total = __pyx_float_0_0;

  /* "pomegranate/distributions.pyx":2288
 * 		counts = {}
 * 		total = 0.0
 * 		for item, weight in zip(items, weights):             # <<<<<<<<<<<<<<
 * 			item = tuple(item)
 * 
 */
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_items);
  __Pyx_INCREF(__pyx_v_weights);
  __Pyx_GIVEREF(__pyx_v_weights);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_weights);
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
    __pyx_t_4 = __pyx_t_5; __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_8(__pyx_t_4);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
      PyObject* sequence = __pyx_t_5;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
      index = 0; __pyx_t_6 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_6)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 1; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_10 = NULL;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L10_unpacking_done;
      __pyx_L9_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_10 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L10_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_weight, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "pomegranate/distributions.pyx":2289
 * 		total = 0.0
 * 		for item, weight in zip(items, weights):
 * 			item = tuple(item)             # <<<<<<<<<<<<<<
 * 
 * 			counts[item] = counts.get(item, 0) + weight
 */
    __pyx_t_5 = PySequence_Tuple(__pyx_v_item); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "pomegranate/distributions.pyx":2291
 * 			item = tuple(item)
 * 
 * 			counts[item] = counts.get(item, 0) + weight             # <<<<<<<<<<<<<<
 * 			total += weight
 * 
 */
    __pyx_t_5 = __Pyx_PyDict_GetItemDefault(__pyx_v_counts, __pyx_v_item, __pyx_int_0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = PyNumber_Add(__pyx_t_5, __pyx_v_weight); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(PyDict_SetItem(__pyx_v_counts, __pyx_v_item, __pyx_t_7) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "pomegranate/distributions.pyx":2292
 * 
 * 			counts[item] = counts.get(item, 0) + weight
 * 			total += weight             # <<<<<<<<<<<<<<
 * 
 * 		values = numpy.zeros_like(self.parameters[0])
 */
    __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_total, __pyx_v_weight); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF_SET(__pyx_v_total, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "pomegranate/distributions.pyx":2288
 * 		counts = {}
 * 		total = 0.0
 * 		for item, weight in zip(items, weights):             # <<<<<<<<<<<<<<
 * 			item = tuple(item)
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2294
 * 			total += weight
 * 
 * 		values = numpy.zeros_like(self.parameters[0])             # <<<<<<<<<<<<<<
 * 		keys = self.parameters[2]
 * 
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_zeros_like); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(__pyx_v_self->parameters == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, PyList_GET_ITEM(__pyx_v_self->parameters, 0)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL;
    __Pyx_INCREF(PyList_GET_ITEM(__pyx_v_self->parameters, 0));
    __Pyx_GIVEREF(PyList_GET_ITEM(__pyx_v_self->parameters, 0));
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, PyList_GET_ITEM(__pyx_v_self->parameters, 0));
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_values = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2295
 * 
 * 		values = numpy.zeros_like(self.parameters[0])
 * 		keys = self.parameters[2]             # <<<<<<<<<<<<<<
 * 
 * 		for key in self.parameters[2].keys():
 */
  if (unlikely(__pyx_v_self->parameters == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyList_GET_ITEM(__pyx_v_self->parameters, 2);
  __Pyx_INCREF(__pyx_t_4);
  __pyx_v_keys = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "pomegranate/distributions.pyx":2297
 * 		keys = self.parameters[2]
 * 
 * 		for key in self.parameters[2].keys():             # <<<<<<<<<<<<<<
 * 			count = counts.get( key, 0.0 )
 * 			probability = count / total
 */
  if (unlikely(__pyx_v_self->parameters == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(PyList_GET_ITEM(__pyx_v_self->parameters, 2), __pyx_n_s_keys); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_6) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5); __pyx_t_2 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_8(__pyx_t_5);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":2298
 * 
 * 		for key in self.parameters[2].keys():
 * 			count = counts.get( key, 0.0 )             # <<<<<<<<<<<<<<
 * 			probability = count / total
 * 			values[keys[key]] = _log(probability)
 */
    __pyx_t_4 = __Pyx_PyDict_GetItemDefault(__pyx_v_counts, __pyx_v_key, __pyx_float_0_0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XDECREF_SET(__pyx_v_count, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":2299
 * 		for key in self.parameters[2].keys():
 * 			count = counts.get( key, 0.0 )
 * 			probability = count / total             # <<<<<<<<<<<<<<
 * 			values[keys[key]] = _log(probability)
 * 
 */
    __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_v_count, __pyx_v_total); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XDECREF_SET(__pyx_v_probability, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":2300
 * 			count = counts.get( key, 0.0 )
 * 			probability = count / total
 * 			values[keys[key]] = _log(probability)             # <<<<<<<<<<<<<<
 * 
 * 		self.parameters[0] = values
 */
    __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_v_probability); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyFloat_FromDouble(__pyx_f_11pomegranate_5utils__log(__pyx_t_11)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyObject_GetItem(__pyx_v_keys, __pyx_v_key); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_6);
    if (unlikely(PyObject_SetItem(__pyx_v_values, __pyx_t_6, __pyx_t_4) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pomegranate/distributions.pyx":2297
 * 		keys = self.parameters[2]
 * 
 * 		for key in self.parameters[2].keys():             # <<<<<<<<<<<<<<
 * 			count = counts.get( key, 0.0 )
 * 			probability = count / total
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "pomegranate/distributions.pyx":2302
 * 			values[keys[key]] = _log(probability)
 * 
 * 		self.parameters[0] = values             # <<<<<<<<<<<<<<
 */
  if (unlikely(__pyx_v_self->parameters == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (unlikely(__Pyx_SetItemInt(__pyx_v_self->parameters, 0, __pyx_v_values, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "pomegranate/distributions.pyx":2266
 * 		return DiscreteDistribution( d )
 * 
 * 	def from_sample( self, items, weights=None, inertia=0.0, pseudocount=0. ):             # <<<<<<<<<<<<<<
 * 		"""
 * 		Update the table based on the data.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pomegranate.distributions.JointProbabilityTable.from_sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_counts);
  __Pyx_XDECREF(__pyx_v_total);
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_XDECREF(__pyx_v_weight);
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XDECREF(__pyx_v_keys);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_count);
  __Pyx_XDECREF(__pyx_v_probability);
  __Pyx_XDECREF(__pyx_v_weights);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pomegranate/distributions.pxd":91
 * 
 * cdef class JointProbabilityTable( MultivariateDistribution ):
 * 	cdef public list parameters             # <<<<<<<<<<<<<<
 */

/* Python wrapper */
static PyObject *__pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_10parameters_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_10parameters_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_10parameters___get__(((struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_10parameters___get__(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->parameters);
  __pyx_r = __pyx_v_self->parameters;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_10parameters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_10parameters_2__set__(((struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_10parameters_2__set__(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyList_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->parameters);
  __Pyx_DECREF(__pyx_v_self->parameters);
  __pyx_v_self->parameters = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pomegranate.distributions.JointProbabilityTable.parameters.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_10parameters_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_10parameters_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_10parameters_4__del__(((struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_11pomegranate_13distributions_21JointProbabilityTable_10parameters_4__del__(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->parameters);
  __Pyx_DECREF(__pyx_v_self->parameters);
  __pyx_v_self->parameters = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197
 *         # experimental exception made for __getbuffer__ and __releasebuffer__
 *         # -- the details of this may change.
 *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fullfill the PEP.
 */

/* Python wrapper */
static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_v_copy_shape;
  int __pyx_v_i;
  int __pyx_v_ndim;
  int __pyx_v_endian_detector;
  int __pyx_v_little_endian;
  int __pyx_v_t;
  char *__pyx_v_f;
  PyArray_Descr *__pyx_v_descr = 0;
  int __pyx_v_offset;
  int __pyx_v_hasfields;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  char *__pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getbuffer__", 0);
  if (__pyx_v_info != NULL) {
    __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(__pyx_v_info->obj);
  }

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":203
 *             # of flags
 * 
 *             if info == NULL: return             # <<<<<<<<<<<<<<
 * 
 *             cdef int copy_shape, i, ndim
 */
  __pyx_t_1 = ((__pyx_v_info == NULL) != 0);
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":206
 * 
 *             cdef int copy_shape, i, ndim
 *             cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 * 
 */
  __pyx_v_endian_detector = 1;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":207
 *             cdef int copy_shape, i, ndim
 *             cdef int endian_detector = 1
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
 * 
 *             ndim = PyArray_NDIM(self)
 */
  __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":209
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 * 
 *             ndim = PyArray_NDIM(self)             # <<<<<<<<<<<<<<
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  __pyx_v_ndim = PyArray_NDIM(__pyx_v_self);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211
 *             ndim = PyArray_NDIM(self)
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 copy_shape = 1
 *             else:
 */
  __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
  if (__pyx_t_1) {

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":212
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 copy_shape = 1             # <<<<<<<<<<<<<<
 *             else:
 *                 copy_shape = 0
 */
    __pyx_v_copy_shape = 1;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211
 *             ndim = PyArray_NDIM(self)
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 copy_shape = 1
 *             else:
 */
    goto __pyx_L4;
  }

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":214
 *                 copy_shape = 1
 *             else:
 *                 copy_shape = 0             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 */
  /*else*/ {
    __pyx_v_copy_shape = 0;
  }
  __pyx_L4:;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216
 *                 copy_shape = 0
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")
 */
  __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L6_bool_binop_done;
  }

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":217
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 */
  __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L6_bool_binop_done:;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216
 *                 copy_shape = 0
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")
 */
  if (__pyx_t_1) {

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216
 *                 copy_shape = 0
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")
 */
  }

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 */
  __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L9_bool_binop_done;
  }

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":221
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 * 
 */
  __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L9_bool_binop_done:;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 */
  if (__pyx_t_1) {

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
 * 
 *             info.buf = PyArray_DATA(self)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 */
  }

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":224
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 * 
 *             info.buf = PyArray_DATA(self)             # <<<<<<<<<<<<<<
 *             info.ndim = ndim
 *             if copy_shape:
 */
  __pyx_v_info->buf = PyArray_DATA(__pyx_v_self);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":225
 * 
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim             # <<<<<<<<<<<<<<
 *             if copy_shape:
 *                 # Allocate new buffer for strides and shape info.
 */
  __pyx_v_info->ndim = __pyx_v_ndim;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim
 *             if copy_shape:             # <<<<<<<<<<<<<<
 *                 # Allocate new buffer for strides and shape info.
 *                 # This is allocated as one block, strides first.
 */
  __pyx_t_1 = (__pyx_v_copy_shape != 0);
  if (__pyx_t_1) {

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":229
 *                 # Allocate new buffer for strides and shape info.
 *                 # This is allocated as one block, strides first.
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)             # <<<<<<<<<<<<<<
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):
 */
    __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2)));

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":230
 *                 # This is allocated as one block, strides first.
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
 *                 info.shape = info.strides + ndim             # <<<<<<<<<<<<<<
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 */
    __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim);

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":231
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):             # <<<<<<<<<<<<<<
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 */
    __pyx_t_4 = __pyx_v_ndim;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_i = __pyx_t_5;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":232
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]             # <<<<<<<<<<<<<<
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 *             else:
 */
      (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]);

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":233
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 *                     info.shape[i] = PyArray_DIMS(self)[i]             # <<<<<<<<<<<<<<
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 */
      (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]);
    }

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim
 *             if copy_shape:             # <<<<<<<<<<<<<<
 *                 # Allocate new buffer for strides and shape info.
 *                 # This is allocated as one block, strides first.
 */
    goto __pyx_L11;
  }

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":235
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)             # <<<<<<<<<<<<<<
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL
 */
  /*else*/ {
    __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self));

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":236
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)             # <<<<<<<<<<<<<<
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)
 */
    __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self));
  }
  __pyx_L11:;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":237
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 *             info.itemsize = PyArray_ITEMSIZE(self)
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 */
  __pyx_v_info->suboffsets = NULL;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":238
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)             # <<<<<<<<<<<<<<
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 * 
 */
  __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":239
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)
 *             info.readonly = not PyArray_ISWRITEABLE(self)             # <<<<<<<<<<<<<<
 * 
 *             cdef int t
 */
  __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0));

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":242
 * 
 *             cdef int t
 *             cdef char* f = NULL             # <<<<<<<<<<<<<<
 *             cdef dtype descr = self.descr
 *             cdef int offset
 */
  __pyx_v_f = NULL;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":243
 *             cdef int t
 *             cdef char* f = NULL
 *             cdef dtype descr = self.descr             # <<<<<<<<<<<<<<
 *             cdef int offset
 * 
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_self->descr);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":246
 *             cdef int offset
 * 
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)             # <<<<<<<<<<<<<<
 * 
 *             if not hasfields and not copy_shape:
 */
  __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)
 * 
 *             if not hasfields and not copy_shape:             # <<<<<<<<<<<<<<
 *                 # do not call releasebuffer
 *                 info.obj = None
 */
  __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L15_bool_binop_done;
  }
  __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L15_bool_binop_done:;
  if (__pyx_t_1) {

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":250
 *             if not hasfields and not copy_shape:
 *                 # do not call releasebuffer
 *                 info.obj = None             # <<<<<<<<<<<<<<
 *             else:
 *                 # need to call releasebuffer
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj);
    __pyx_v_info->obj = Py_None;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)
 * 
 *             if not hasfields and not copy_shape:             # <<<<<<<<<<<<<<
 *                 # do not call releasebuffer
 *                 info.obj = None
 */
    goto __pyx_L14;
  }

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":253
 *             else:
 *                 # need to call releasebuffer
 *                 info.obj = self             # <<<<<<<<<<<<<<
 * 
 *             if not hasfields:
 */
  /*else*/ {
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj);
    __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
  }
  __pyx_L14:;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":255
 *                 info.obj = self
 * 
 *             if not hasfields:             # <<<<<<<<<<<<<<
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or
 */
  __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0);
  if (__pyx_t_1) {

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":256
 * 
 *             if not hasfields:
 *                 t = descr.type_num             # <<<<<<<<<<<<<<
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):
 */
    __pyx_t_4 = __pyx_v_descr->type_num;
    __pyx_v_t = __pyx_t_4;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257
 *             if not hasfields:
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 */
    __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0);
    if (!__pyx_t_2) {
      goto __pyx_L20_next_or;
    } else {
    }
    __pyx_t_2 = (__pyx_v_little_endian != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L19_bool_binop_done;
    }
    __pyx_L20_next_or:;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":258
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):             # <<<<<<<<<<<<<<
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"
 */
    __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L19_bool_binop_done;
    }
    __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L19_bool_binop_done:;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257
 *             if not hasfields:
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 */
    if (__pyx_t_1) {

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257
 *             if not hasfields:
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 */
    }

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":260
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"
 */
    switch (__pyx_v_t) {
      case NPY_BYTE:
      __pyx_v_f = __pyx_k_b;
      break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":261
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"
 */
      case NPY_UBYTE:
      __pyx_v_f = __pyx_k_B;
      break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":262
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"
 */
      case NPY_SHORT:
      __pyx_v_f = __pyx_k_h;
      break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":263
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"
 */
      case NPY_USHORT:
      __pyx_v_f = __pyx_k_H;
      break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":264
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"
 */
      case NPY_INT:
      __pyx_v_f = __pyx_k_i;
      break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":265
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"
 */
      case NPY_UINT:
      __pyx_v_f = __pyx_k_I;
      break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":266
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"
 */
      case NPY_LONG:
      __pyx_v_f = __pyx_k_l;
      break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":267
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 */
      case NPY_ULONG:
      __pyx_v_f = __pyx_k_L;
      break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":268
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"
 */
      case NPY_LONGLONG:
      __pyx_v_f = __pyx_k_q;
      break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":269
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"
 */
      case NPY_ULONGLONG:
      __pyx_v_f = __pyx_k_Q;
      break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":270
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 */
      case NPY_FLOAT:
      __pyx_v_f = __pyx_k_f;
      break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":271
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 */
      case NPY_DOUBLE:
      __pyx_v_f = __pyx_k_d;
      break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":272
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 */
      case NPY_LONGDOUBLE:
      __pyx_v_f = __pyx_k_g;
      break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":273
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 */
      case NPY_CFLOAT:
      __pyx_v_f = __pyx_k_Zf;
      break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":274
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"
 */
      case NPY_CDOUBLE:
      __pyx_v_f = __pyx_k_Zd;
      break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":275
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 */
      case NPY_CLONGDOUBLE:
      __pyx_v_f = __pyx_k_Zg;
      break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":276
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 */
      case NPY_OBJECT:
      __pyx_v_f = __pyx_k_O;
      break;
      default:

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":278
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *                 info.format = f
 *                 return
 */
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      break;
    }

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":279
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f             # <<<<<<<<<<<<<<
 *                 return
 *             else:
 */
    __pyx_v_info->format = __pyx_v_f;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":280
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f
 *                 return             # <<<<<<<<<<<<<<
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":255
 *                 info.obj = self
 * 
 *             if not hasfields:             # <<<<<<<<<<<<<<
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or
 */
  }

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":282
 *                 return
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)             # <<<<<<<<<<<<<<
 *                 info.format[0] = c'^' # Native data types, manual alignment
 *                 offset = 0
 */
  /*else*/ {
    __pyx_v_info->format = ((char *)malloc(255));

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":283
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 *                 info.format[0] = c'^' # Native data types, manual alignment             # <<<<<<<<<<<<<<
 *                 offset = 0
 *                 f = _util_dtypestring(descr, info.format + 1,
 */
    (__pyx_v_info->format[0]) = '^';

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":284
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 *                 info.format[0] = c'^' # Native data types, manual alignment
 *                 offset = 0             # <<<<<<<<<<<<<<
 *                 f = _util_dtypestring(descr, info.format + 1,
 *                                       info.format + _buffer_format_string_len,
 */
    __pyx_v_offset = 0;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":285
 *                 info.format[0] = c'^' # Native data types, manual alignment
 *                 offset = 0
 *                 f = _util_dtypestring(descr, info.format + 1,             # <<<<<<<<<<<<<<
 *                                       info.format + _buffer_format_string_len,
 *                                       &offset)
 */
    __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_f = __pyx_t_7;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":288
 *                                       info.format + _buffer_format_string_len,
 *                                       &offset)
 *                 f[0] = c'\0' # Terminate format string             # <<<<<<<<<<<<<<
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 */
    (__pyx_v_f[0]) = '\x00';
  }

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197
 *         # experimental exception made for __getbuffer__ and __releasebuffer__
 *         # -- the details of this may change.
 *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fullfill the PEP.
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) {
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
  }
  goto __pyx_L2;
  __pyx_L0:;
  if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
    __Pyx_GOTREF(Py_None);
    __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
  }
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_descr);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":290
 *                 f[0] = c'\0' # Terminate format string
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 */

/* Python wrapper */
static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
  __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__releasebuffer__", 0);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0);
  if (__pyx_t_1) {

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":292
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)             # <<<<<<<<<<<<<<
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 stdlib.free(info.strides)
 */
    free(__pyx_v_info->format);

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  }

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":293
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.strides)
 *                 # info.shape was stored after info.strides in the same block
 */
  __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
  if (__pyx_t_1) {

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":294
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 stdlib.free(info.strides)             # <<<<<<<<<<<<<<
 *                 # info.shape was stored after info.strides in the same block
 * 
 */
    free(__pyx_v_info->strides);

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":293
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.strides)
 *                 # info.shape was stored after info.strides in the same block
 */
  }

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":290
 *                 f[0] = c'\0' # Terminate format string
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":770
 * ctypedef npy_cdouble     complex_t
 * 
 * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":771
 * 
 * cdef inline object PyArray_MultiIterNew1(a):
 *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":770
 * ctypedef npy_cdouble     complex_t
 * 
 * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":773
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":774
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":773
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":776
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":777
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":776
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":779
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":780
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":779
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":782
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":783
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":782
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":785
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:             # <<<<<<<<<<<<<<
 *     # Recursive utility function used in __getbuffer__ to get format
 *     # string. The new location in the format string is returned.
 */

static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) {
  PyArray_Descr *__pyx_v_child = 0;
  int __pyx_v_endian_detector;
  int __pyx_v_little_endian;
  PyObject *__pyx_v_fields = 0;
  PyObject *__pyx_v_childname = NULL;
  PyObject *__pyx_v_new_offset = NULL;
  PyObject *__pyx_v_t = NULL;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  long __pyx_t_8;
  char *__pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_util_dtypestring", 0);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":790
 * 
 *     cdef dtype child
 *     cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 *     cdef tuple fields
 */
  __pyx_v_endian_detector = 1;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":791
 *     cdef dtype child
 *     cdef int endian_detector = 1
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
 *     cdef tuple fields
 * 
 */
  __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794
 *     cdef tuple fields
 * 
 *     for childname in descr.names:             # <<<<<<<<<<<<<<
 *         fields = descr.fields[childname]
 *         child, new_offset = fields
 */
  if (unlikely(__pyx_v_descr->names == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":795
 * 
 *     for childname in descr.names:
 *         fields = descr.fields[childname]             # <<<<<<<<<<<<<<
 *         child, new_offset = fields
 * 
 */
    if (unlikely(__pyx_v_descr->fields == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":796
 *     for childname in descr.names:
 *         fields = descr.fields[childname]
 *         child, new_offset = fields             # <<<<<<<<<<<<<<
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:
 */
    if (likely(__pyx_v_fields != Py_None)) {
      PyObject* sequence = __pyx_v_fields;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      #endif
    } else {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3));
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798
 *         child, new_offset = fields
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 */
    __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0);
    if (__pyx_t_6) {

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
 * 
 *         if ((child.byteorder == c'>' and little_endian) or
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798
 *         child, new_offset = fields
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 */
    }

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 *         if ((child.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")
 */
    __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0);
    if (!__pyx_t_7) {
      goto __pyx_L8_next_or;
    } else {
    }
    __pyx_t_7 = (__pyx_v_little_endian != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_L8_next_or:;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":802
 * 
 *         if ((child.byteorder == c'>' and little_endian) or
 *             (child.byteorder == c'<' and not little_endian)):             # <<<<<<<<<<<<<<
 *             raise ValueError(u"Non-native byte order not supported")
 *             # One could encode it in the format string and have Cython
 */
    __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0);
    __pyx_t_6 = __pyx_t_7;
    __pyx_L7_bool_binop_done:;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 *         if ((child.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")
 */
    if (__pyx_t_6) {

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803
 *         if ((child.byteorder == c'>' and little_endian) or
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *             # One could encode it in the format string and have Cython
 *             # complain instead, BUT: < and > in format strings also imply
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 *         if ((child.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")
 */
    }

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":813
 * 
 *         # Output padding bytes
 *         while offset[0] < new_offset:             # <<<<<<<<<<<<<<
 *             f[0] = 120 # "x"; pad byte
 *             f += 1
 */
    while (1) {
      __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!__pyx_t_6) break;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":814
 *         # Output padding bytes
 *         while offset[0] < new_offset:
 *             f[0] = 120 # "x"; pad byte             # <<<<<<<<<<<<<<
 *             f += 1
 *             offset[0] += 1
 */
      (__pyx_v_f[0]) = 120;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":815
 *         while offset[0] < new_offset:
 *             f[0] = 120 # "x"; pad byte
 *             f += 1             # <<<<<<<<<<<<<<
 *             offset[0] += 1
 * 
 */
      __pyx_v_f = (__pyx_v_f + 1);

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":816
 *             f[0] = 120 # "x"; pad byte
 *             f += 1
 *             offset[0] += 1             # <<<<<<<<<<<<<<
 * 
 *         offset[0] += child.itemsize
 */
      __pyx_t_8 = 0;
      (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1);
    }

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":818
 *             offset[0] += 1
 * 
 *         offset[0] += child.itemsize             # <<<<<<<<<<<<<<
 * 
 *         if not PyDataType_HASFIELDS(child):
 */
    __pyx_t_8 = 0;
    (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize);

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":820
 *         offset[0] += child.itemsize
 * 
 *         if not PyDataType_HASFIELDS(child):             # <<<<<<<<<<<<<<
 *             t = child.type_num
 *             if end - f < 5:
 */
    __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0);
    if (__pyx_t_6) {

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":821
 * 
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num             # <<<<<<<<<<<<<<
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")
 */
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":822
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num
 *             if end - f < 5:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(u"Format string allocated too short.")
 * 
 */
      __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0);
      if (__pyx_t_6) {

        /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823
 *             t = child.type_num
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 */
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        {__pyx_filename = __pyx_f[2]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":822
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num
 *             if end - f < 5:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(u"Format string allocated too short.")
 * 
 */
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":826
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"             # <<<<<<<<<<<<<<
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 98;
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":827
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"             # <<<<<<<<<<<<<<
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 66;
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":828
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"             # <<<<<<<<<<<<<<
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 104;
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":829
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"             # <<<<<<<<<<<<<<
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 72;
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":830
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"             # <<<<<<<<<<<<<<
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 105;
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":831
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 73;
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":832
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"             # <<<<<<<<<<<<<<
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 108;
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":833
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 76;
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":834
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"             # <<<<<<<<<<<<<<
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 113;
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":835
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"             # <<<<<<<<<<<<<<
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 81;
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":836
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"             # <<<<<<<<<<<<<<
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 102;
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":837
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 100;
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":838
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"             # <<<<<<<<<<<<<<
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 103;
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":839
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf             # <<<<<<<<<<<<<<
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 102;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":840
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd             # <<<<<<<<<<<<<<
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 100;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":841
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg             # <<<<<<<<<<<<<<
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 *             else:
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 103;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":842
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 79;
        goto __pyx_L15;
      }

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":844
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *             f += 1
 *         else:
 */
      /*else*/ {
        __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        {__pyx_filename = __pyx_f[2]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L15:;

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":845
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *             f += 1             # <<<<<<<<<<<<<<
 *         else:
 *             # Cython ignores struct boundary information ("T{...}"),
 */
      __pyx_v_f = (__pyx_v_f + 1);

      /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":820
 *         offset[0] += child.itemsize
 * 
 *         if not PyDataType_HASFIELDS(child):             # <<<<<<<<<<<<<<
 *             t = child.type_num
 *             if end - f < 5:
 */
      goto __pyx_L13;
    }

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":849
 *             # Cython ignores struct boundary information ("T{...}"),
 *             # so don't output it
 *             f = _util_dtypestring(child, f, end, offset)             # <<<<<<<<<<<<<<
 *     return f
 * 
 */
    /*else*/ {
      __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_f = __pyx_t_9;
    }
    __pyx_L13:;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794
 *     cdef tuple fields
 * 
 *     for childname in descr.names:             # <<<<<<<<<<<<<<
 *         fields = descr.fields[childname]
 *         child, new_offset = fields
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":850
 *             # so don't output it
 *             f = _util_dtypestring(child, f, end, offset)
 *     return f             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_f;
  goto __pyx_L0;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":785
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:             # <<<<<<<<<<<<<<
 *     # Recursive utility function used in __getbuffer__ to get format
 *     # string. The new location in the format string is returned.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_child);
  __Pyx_XDECREF(__pyx_v_fields);
  __Pyx_XDECREF(__pyx_v_childname);
  __Pyx_XDECREF(__pyx_v_new_offset);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966
 * 
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *      cdef PyObject* baseptr
 *      if base is None:
 */

static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
  PyObject *__pyx_v_baseptr;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("set_array_base", 0);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":968
 * cdef inline void set_array_base(ndarray arr, object base):
 *      cdef PyObject* baseptr
 *      if base is None:             # <<<<<<<<<<<<<<
 *          baseptr = NULL
 *      else:
 */
  __pyx_t_1 = (__pyx_v_base == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":969
 *      cdef PyObject* baseptr
 *      if base is None:
 *          baseptr = NULL             # <<<<<<<<<<<<<<
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!
 */
    __pyx_v_baseptr = NULL;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":968
 * cdef inline void set_array_base(ndarray arr, object base):
 *      cdef PyObject* baseptr
 *      if base is None:             # <<<<<<<<<<<<<<
 *          baseptr = NULL
 *      else:
 */
    goto __pyx_L3;
  }

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":971
 *          baseptr = NULL
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!             # <<<<<<<<<<<<<<
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)
 */
  /*else*/ {
    Py_INCREF(__pyx_v_base);

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":972
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!
 *          baseptr = <PyObject*>base             # <<<<<<<<<<<<<<
 *      Py_XDECREF(arr.base)
 *      arr.base = baseptr
 */
    __pyx_v_baseptr = ((PyObject *)__pyx_v_base);
  }
  __pyx_L3:;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":973
 *          Py_INCREF(base) # important to do this before decref below!
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)             # <<<<<<<<<<<<<<
 *      arr.base = baseptr
 * 
 */
  Py_XDECREF(__pyx_v_arr->base);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":974
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)
 *      arr.base = baseptr             # <<<<<<<<<<<<<<
 * 
 * cdef inline object get_array_base(ndarray arr):
 */
  __pyx_v_arr->base = __pyx_v_baseptr;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966
 * 
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *      cdef PyObject* baseptr
 *      if base is None:
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976
 *      arr.base = baseptr
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr.base is NULL:
 *         return None
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("get_array_base", 0);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977
 * 
 * cdef inline object get_array_base(ndarray arr):
 *     if arr.base is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0);
  if (__pyx_t_1) {

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":978
 * cdef inline object get_array_base(ndarray arr):
 *     if arr.base is NULL:
 *         return None             # <<<<<<<<<<<<<<
 *     else:
 *         return <object>arr.base
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;

    /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977
 * 
 * cdef inline object get_array_base(ndarray arr):
 *     if arr.base is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     else:
 */
  }

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":980
 *         return None
 *     else:
 *         return <object>arr.base             # <<<<<<<<<<<<<<
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_arr->base));
    __pyx_r = ((PyObject *)__pyx_v_arr->base);
    goto __pyx_L0;
  }

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976
 *      arr.base = baseptr
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr.base is NULL:
 *         return None
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution __pyx_vtable_11pomegranate_13distributions_Distribution;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_Distribution(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_Distribution *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_Distribution *)o);
  p->__pyx_vtab = __pyx_vtabptr_11pomegranate_13distributions_Distribution;
  p->name = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->summaries = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_11pomegranate_13distributions_12Distribution_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions_Distribution(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions_Distribution *p = (struct __pyx_obj_11pomegranate_13distributions_Distribution *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->name);
  Py_CLEAR(p->summaries);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_11pomegranate_13distributions_Distribution(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions_Distribution *p = (struct __pyx_obj_11pomegranate_13distributions_Distribution *)o;
  if (p->summaries) {
    e = (*v)(p->summaries, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions_Distribution(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions_Distribution *p = (struct __pyx_obj_11pomegranate_13distributions_Distribution *)o;
  tmp = ((PyObject*)p->summaries);
  p->summaries = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_12Distribution_name(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_12Distribution_4name_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_12Distribution_name(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_12Distribution_4name_3__set__(o, v);
  }
  else {
    return __pyx_pw_11pomegranate_13distributions_12Distribution_4name_5__del__(o);
  }
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_12Distribution_summaries(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_12Distribution_9summaries_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_12Distribution_summaries(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_12Distribution_9summaries_3__set__(o, v);
  }
  else {
    return __pyx_pw_11pomegranate_13distributions_12Distribution_9summaries_5__del__(o);
  }
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_12Distribution_frozen(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_12Distribution_6frozen_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_12Distribution_frozen(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_12Distribution_6frozen_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_Distribution[] = {
  {"marginal", (PyCFunction)__pyx_pw_11pomegranate_13distributions_12Distribution_7marginal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_12Distribution_6marginal},
  {"copy", (PyCFunction)__pyx_pw_11pomegranate_13distributions_12Distribution_9copy, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_12Distribution_8copy},
  {"freeze", (PyCFunction)__pyx_pw_11pomegranate_13distributions_12Distribution_11freeze, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_12Distribution_10freeze},
  {"thaw", (PyCFunction)__pyx_pw_11pomegranate_13distributions_12Distribution_13thaw, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_12Distribution_12thaw},
  {"log_probability", (PyCFunction)__pyx_pw_11pomegranate_13distributions_12Distribution_15log_probability, METH_O, __pyx_doc_11pomegranate_13distributions_12Distribution_14log_probability},
  {"sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_12Distribution_17sample, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_12Distribution_16sample},
  {"fit", (PyCFunction)__pyx_pw_11pomegranate_13distributions_12Distribution_19fit, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_12Distribution_18fit},
  {"train", (PyCFunction)__pyx_pw_11pomegranate_13distributions_12Distribution_21train, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_12Distribution_20train},
  {"from_sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_12Distribution_23from_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_12Distribution_22from_sample},
  {"summarize", (PyCFunction)__pyx_pw_11pomegranate_13distributions_12Distribution_25summarize, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_12Distribution_24summarize},
  {"from_summaries", (PyCFunction)__pyx_pw_11pomegranate_13distributions_12Distribution_27from_summaries, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_12Distribution_26from_summaries},
  {"plot", (PyCFunction)__pyx_pw_11pomegranate_13distributions_12Distribution_29plot, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_12Distribution_28plot},
  {"to_json", (PyCFunction)__pyx_pw_11pomegranate_13distributions_12Distribution_31to_json, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_12Distribution_30to_json},
  {"from_json", (PyCFunction)__pyx_pw_11pomegranate_13distributions_12Distribution_33from_json, METH_O, __pyx_doc_11pomegranate_13distributions_12Distribution_32from_json},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11pomegranate_13distributions_Distribution[] = {
  {(char *)"name", __pyx_getprop_11pomegranate_13distributions_12Distribution_name, __pyx_setprop_11pomegranate_13distributions_12Distribution_name, 0, 0},
  {(char *)"summaries", __pyx_getprop_11pomegranate_13distributions_12Distribution_summaries, __pyx_setprop_11pomegranate_13distributions_12Distribution_summaries, 0, 0},
  {(char *)"frozen", __pyx_getprop_11pomegranate_13distributions_12Distribution_frozen, __pyx_setprop_11pomegranate_13distributions_12Distribution_frozen, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_Distribution = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.Distribution", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_Distribution), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_Distribution, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n\tRepresents a probability distribution over whatever the HMM you're making is\n\tsupposed to emit. Ought to be subclassed and have log_probability(), \n\tsample(), and from_sample() overridden. Distribution.name should be \n\toverridden and replaced with a unique name for the distribution type. The \n\tdistribution should be registered by calling register() on the derived \n\tclass, so that Distribution.read() can read it. Any distribution parameters \n\tneed to be floats stored in self.parameters, so they will be properly \n\twritten by write().\n\t", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_Distribution, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_Distribution, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_Distribution, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11pomegranate_13distributions_Distribution, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_Distribution, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_UniformDistribution __pyx_vtable_11pomegranate_13distributions_UniformDistribution;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_UniformDistribution(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_Distribution(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_UniformDistribution *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_UniformDistribution;
  if (unlikely(__pyx_pw_11pomegranate_13distributions_19UniformDistribution_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_19UniformDistribution_parameters(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_19UniformDistribution_10parameters_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_19UniformDistribution_parameters(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_19UniformDistribution_10parameters_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_UniformDistribution[] = {
  {"sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_19UniformDistribution_3sample, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_19UniformDistribution_2sample},
  {"from_sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_19UniformDistribution_5from_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_19UniformDistribution_4from_sample},
  {"summarize", (PyCFunction)__pyx_pw_11pomegranate_13distributions_19UniformDistribution_7summarize, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_19UniformDistribution_6summarize},
  {"from_summaries", (PyCFunction)__pyx_pw_11pomegranate_13distributions_19UniformDistribution_9from_summaries, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_19UniformDistribution_8from_summaries},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11pomegranate_13distributions_UniformDistribution[] = {
  {(char *)"parameters", __pyx_getprop_11pomegranate_13distributions_19UniformDistribution_parameters, __pyx_setprop_11pomegranate_13distributions_19UniformDistribution_parameters, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_UniformDistribution = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.UniformDistribution", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_UniformDistribution), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_Distribution, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "A uniform distribution between two values.", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_Distribution, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_Distribution, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_UniformDistribution, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11pomegranate_13distributions_UniformDistribution, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_UniformDistribution, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_NormalDistribution __pyx_vtable_11pomegranate_13distributions_NormalDistribution;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_NormalDistribution(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_Distribution(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_NormalDistribution *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_NormalDistribution;
  if (unlikely(__pyx_pw_11pomegranate_13distributions_18NormalDistribution_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_18NormalDistribution_parameters(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_18NormalDistribution_10parameters_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_18NormalDistribution_parameters(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_18NormalDistribution_10parameters_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_NormalDistribution[] = {
  {"sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_18NormalDistribution_3sample, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_18NormalDistribution_2sample},
  {"from_sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_18NormalDistribution_5from_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_18NormalDistribution_4from_sample},
  {"summarize", (PyCFunction)__pyx_pw_11pomegranate_13distributions_18NormalDistribution_7summarize, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_18NormalDistribution_6summarize},
  {"from_summaries", (PyCFunction)__pyx_pw_11pomegranate_13distributions_18NormalDistribution_9from_summaries, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_18NormalDistribution_8from_summaries},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11pomegranate_13distributions_NormalDistribution[] = {
  {(char *)"parameters", __pyx_getprop_11pomegranate_13distributions_18NormalDistribution_parameters, __pyx_setprop_11pomegranate_13distributions_18NormalDistribution_parameters, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_NormalDistribution = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.NormalDistribution", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_NormalDistribution), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_Distribution, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n\tA normal distribution based on a mean and standard deviation.\n\t", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_Distribution, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_Distribution, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_NormalDistribution, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11pomegranate_13distributions_NormalDistribution, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_NormalDistribution, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_LogNormalDistribution __pyx_vtable_11pomegranate_13distributions_LogNormalDistribution;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_LogNormalDistribution(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_Distribution(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_LogNormalDistribution;
  if (unlikely(__pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_21LogNormalDistribution_parameters(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_10parameters_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_21LogNormalDistribution_parameters(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_10parameters_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_LogNormalDistribution[] = {
  {"sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_3sample, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_21LogNormalDistribution_2sample},
  {"from_sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_5from_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_21LogNormalDistribution_4from_sample},
  {"summarize", (PyCFunction)__pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_7summarize, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_21LogNormalDistribution_6summarize},
  {"from_summaries", (PyCFunction)__pyx_pw_11pomegranate_13distributions_21LogNormalDistribution_9from_summaries, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_21LogNormalDistribution_8from_summaries},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11pomegranate_13distributions_LogNormalDistribution[] = {
  {(char *)"parameters", __pyx_getprop_11pomegranate_13distributions_21LogNormalDistribution_parameters, __pyx_setprop_11pomegranate_13distributions_21LogNormalDistribution_parameters, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_LogNormalDistribution = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.LogNormalDistribution", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_LogNormalDistribution), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_Distribution, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n\tRepresents a lognormal distribution over non-negative floats.\n\t", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_Distribution, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_Distribution, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_LogNormalDistribution, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11pomegranate_13distributions_LogNormalDistribution, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_LogNormalDistribution, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_ExponentialDistribution __pyx_vtable_11pomegranate_13distributions_ExponentialDistribution;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_ExponentialDistribution(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_Distribution(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_ExponentialDistribution;
  if (unlikely(__pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_23ExponentialDistribution_parameters(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_10parameters_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_23ExponentialDistribution_parameters(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_10parameters_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_ExponentialDistribution[] = {
  {"sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_3sample, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_23ExponentialDistribution_2sample},
  {"from_sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_5from_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_23ExponentialDistribution_4from_sample},
  {"summarize", (PyCFunction)__pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_7summarize, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_23ExponentialDistribution_6summarize},
  {"from_summaries", (PyCFunction)__pyx_pw_11pomegranate_13distributions_23ExponentialDistribution_9from_summaries, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_23ExponentialDistribution_8from_summaries},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11pomegranate_13distributions_ExponentialDistribution[] = {
  {(char *)"parameters", __pyx_getprop_11pomegranate_13distributions_23ExponentialDistribution_parameters, __pyx_setprop_11pomegranate_13distributions_23ExponentialDistribution_parameters, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_ExponentialDistribution = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.ExponentialDistribution", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_ExponentialDistribution), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_Distribution, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n\tRepresents an exponential distribution on non-negative floats.\n\t", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_Distribution, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_Distribution, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_ExponentialDistribution, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11pomegranate_13distributions_ExponentialDistribution, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_ExponentialDistribution, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_BetaDistribution __pyx_vtable_11pomegranate_13distributions_BetaDistribution;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_BetaDistribution(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_Distribution(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_BetaDistribution *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_BetaDistribution;
  return o;
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_16BetaDistribution_parameters(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_16BetaDistribution_10parameters_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_16BetaDistribution_parameters(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_16BetaDistribution_10parameters_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_BetaDistribution[] = {
  {"sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_16BetaDistribution_3sample, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_16BetaDistribution_2sample},
  {"from_sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_16BetaDistribution_5from_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_16BetaDistribution_4from_sample},
  {"summarize", (PyCFunction)__pyx_pw_11pomegranate_13distributions_16BetaDistribution_7summarize, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_16BetaDistribution_6summarize},
  {"from_summaries", (PyCFunction)__pyx_pw_11pomegranate_13distributions_16BetaDistribution_9from_summaries, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_16BetaDistribution_8from_summaries},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11pomegranate_13distributions_BetaDistribution[] = {
  {(char *)"parameters", __pyx_getprop_11pomegranate_13distributions_16BetaDistribution_parameters, __pyx_setprop_11pomegranate_13distributions_16BetaDistribution_parameters, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_BetaDistribution = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.BetaDistribution", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_BetaDistribution), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_Distribution, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n\tThis distribution represents a beta distribution, parameterized using\n\talpha/beta, which are both shape parameters. ML estimation is done\n\t", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_Distribution, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_Distribution, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_BetaDistribution, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11pomegranate_13distributions_BetaDistribution, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_11pomegranate_13distributions_16BetaDistribution_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_BetaDistribution, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_GammaDistribution __pyx_vtable_11pomegranate_13distributions_GammaDistribution;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_GammaDistribution(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_Distribution(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_GammaDistribution *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_GammaDistribution;
  if (unlikely(__pyx_pw_11pomegranate_13distributions_17GammaDistribution_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_17GammaDistribution_parameters(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_17GammaDistribution_10parameters_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_17GammaDistribution_parameters(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_17GammaDistribution_10parameters_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_GammaDistribution[] = {
  {"sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_17GammaDistribution_3sample, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_17GammaDistribution_2sample},
  {"from_sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_17GammaDistribution_5from_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_17GammaDistribution_4from_sample},
  {"summarize", (PyCFunction)__pyx_pw_11pomegranate_13distributions_17GammaDistribution_7summarize, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_17GammaDistribution_6summarize},
  {"from_summaries", (PyCFunction)__pyx_pw_11pomegranate_13distributions_17GammaDistribution_9from_summaries, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_17GammaDistribution_8from_summaries},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11pomegranate_13distributions_GammaDistribution[] = {
  {(char *)"parameters", __pyx_getprop_11pomegranate_13distributions_17GammaDistribution_parameters, __pyx_setprop_11pomegranate_13distributions_17GammaDistribution_parameters, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_GammaDistribution = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.GammaDistribution", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_GammaDistribution), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_Distribution, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n\tThis distribution represents a gamma distribution, parameterized in the \n\talpha/beta (shape/rate) parameterization. ML estimation for a gamma \n\tdistribution, taking into account weights on the data, is nontrivial, and I \n\twas unable to find a good theoretical source for how to do it, so I have \n\tcobbled together a solution here from less-reputable sources.\n\t", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_Distribution, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_Distribution, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_GammaDistribution, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11pomegranate_13distributions_GammaDistribution, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_GammaDistribution, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_DiscreteDistribution __pyx_vtable_11pomegranate_13distributions_DiscreteDistribution;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_DiscreteDistribution(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_Distribution(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_DiscreteDistribution;
  p->dist = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->log_dist = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->encoded_keys = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions_DiscreteDistribution(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *p = (struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_3__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->dist);
  Py_CLEAR(p->log_dist);
  Py_CLEAR(p->encoded_keys);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_11pomegranate_13distributions_Distribution(o);
}

static int __pyx_tp_traverse_11pomegranate_13distributions_DiscreteDistribution(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *p = (struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)o;
  e = __pyx_tp_traverse_11pomegranate_13distributions_Distribution(o, v, a); if (e) return e;
  if (p->dist) {
    e = (*v)(p->dist, a); if (e) return e;
  }
  if (p->log_dist) {
    e = (*v)(p->log_dist, a); if (e) return e;
  }
  if (p->encoded_keys) {
    e = (*v)(p->encoded_keys, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions_DiscreteDistribution(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *p = (struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *)o;
  __pyx_tp_clear_11pomegranate_13distributions_Distribution(o);
  tmp = ((PyObject*)p->dist);
  p->dist = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->log_dist);
  p->log_dist = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->encoded_keys);
  p->encoded_keys = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_20DiscreteDistribution_parameters(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_10parameters_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_20DiscreteDistribution_parameters(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_10parameters_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_DiscreteDistribution[] = {
  {"equals", (PyCFunction)__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_9equals, METH_O, __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_8equals},
  {"clamp", (PyCFunction)__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_11clamp, METH_O, __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_10clamp},
  {"keys", (PyCFunction)__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_13keys, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_12keys},
  {"items", (PyCFunction)__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_15items, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_14items},
  {"values", (PyCFunction)__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_17values, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_16values},
  {"mle", (PyCFunction)__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_19mle, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_18mle},
  {"encode", (PyCFunction)__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_21encode, METH_O, __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_20encode},
  {"log_probability", (PyCFunction)__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_23log_probability, METH_O, __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_22log_probability},
  {"sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_25sample, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_24sample},
  {"from_sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_27from_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_26from_sample},
  {"summarize", (PyCFunction)__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_29summarize, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_28summarize},
  {"from_summaries", (PyCFunction)__pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_31from_summaries, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_30from_summaries},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11pomegranate_13distributions_DiscreteDistribution[] = {
  {(char *)"parameters", __pyx_getprop_11pomegranate_13distributions_20DiscreteDistribution_parameters, __pyx_setprop_11pomegranate_13distributions_20DiscreteDistribution_parameters, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_DiscreteDistribution = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  __pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_7__mul__, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_DiscreteDistribution = {
  __pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_5__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_DiscreteDistribution = {
  __pyx_pw_11pomegranate_13distributions_20DiscreteDistribution_5__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_DiscreteDistribution = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.DiscreteDistribution", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_DiscreteDistribution, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  &__pyx_tp_as_number_DiscreteDistribution, /*tp_as_number*/
  &__pyx_tp_as_sequence_DiscreteDistribution, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_DiscreteDistribution, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n\tA discrete distribution, made up of characters and their probabilities,\n\tassuming that these probabilities will sum to 1.0. \n\t", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_DiscreteDistribution, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_DiscreteDistribution, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_DiscreteDistribution, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11pomegranate_13distributions_DiscreteDistribution, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_DiscreteDistribution, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_LambdaDistribution __pyx_vtable_11pomegranate_13distributions_LambdaDistribution;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_LambdaDistribution(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_LambdaDistribution *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_Distribution(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_LambdaDistribution *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_LambdaDistribution;
  return o;
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_LambdaDistribution[] = {
  {"log_probability", (PyCFunction)__pyx_pw_11pomegranate_13distributions_18LambdaDistribution_3log_probability, METH_O, __pyx_doc_11pomegranate_13distributions_18LambdaDistribution_2log_probability},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_LambdaDistribution = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.LambdaDistribution", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_LambdaDistribution), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_Distribution, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n\tA distribution which takes in an arbitrary lambda function, and returns\n\tprobabilities associated with whatever that function gives. For example...\n\n\tfunc = lambda x: log(1) if 2 > x > 1 else log(0)\n\tdistribution = LambdaDistribution( func )\n\tprint distribution.log_probability( 1 ) # 1\n\tprint distribution.log_probability( -100 ) # 0\n\n\tThis assumes the lambda function returns the log probability, not the\n\tuntransformed probability.\n\t", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_Distribution, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_Distribution, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_LambdaDistribution, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_11pomegranate_13distributions_18LambdaDistribution_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_LambdaDistribution, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_KernelDensity __pyx_vtable_11pomegranate_13distributions_KernelDensity;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_KernelDensity(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_KernelDensity *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_Distribution(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_KernelDensity *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_KernelDensity;
  p->points_ndarray = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->weights_ndarray = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_11pomegranate_13distributions_13KernelDensity_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions_KernelDensity(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions_KernelDensity *p = (struct __pyx_obj_11pomegranate_13distributions_KernelDensity *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->points_ndarray);
  Py_CLEAR(p->weights_ndarray);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_11pomegranate_13distributions_Distribution(o);
}

static int __pyx_tp_traverse_11pomegranate_13distributions_KernelDensity(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions_KernelDensity *p = (struct __pyx_obj_11pomegranate_13distributions_KernelDensity *)o;
  e = __pyx_tp_traverse_11pomegranate_13distributions_Distribution(o, v, a); if (e) return e;
  if (p->points_ndarray) {
    e = (*v)(((PyObject*)p->points_ndarray), a); if (e) return e;
  }
  if (p->weights_ndarray) {
    e = (*v)(((PyObject*)p->weights_ndarray), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions_KernelDensity(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions_KernelDensity *p = (struct __pyx_obj_11pomegranate_13distributions_KernelDensity *)o;
  __pyx_tp_clear_11pomegranate_13distributions_Distribution(o);
  tmp = ((PyObject*)p->points_ndarray);
  p->points_ndarray = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->weights_ndarray);
  p->weights_ndarray = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_13KernelDensity_parameters(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_13KernelDensity_10parameters_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_13KernelDensity_parameters(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_13KernelDensity_10parameters_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_KernelDensity[] = {
  {"from_sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_13KernelDensity_3from_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_13KernelDensity_2from_sample},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11pomegranate_13distributions_KernelDensity[] = {
  {(char *)"parameters", __pyx_getprop_11pomegranate_13distributions_13KernelDensity_parameters, __pyx_setprop_11pomegranate_13distributions_13KernelDensity_parameters, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_KernelDensity = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.KernelDensity", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_KernelDensity), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_KernelDensity, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "An abstract kernel density, with shared properties and methods.", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_KernelDensity, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_KernelDensity, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_KernelDensity, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11pomegranate_13distributions_KernelDensity, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_KernelDensity, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_GaussianKernelDensity __pyx_vtable_11pomegranate_13distributions_GaussianKernelDensity;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_GaussianKernelDensity(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_GaussianKernelDensity *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_KernelDensity(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_GaussianKernelDensity *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_GaussianKernelDensity;
  if (unlikely(__pyx_pw_11pomegranate_13distributions_21GaussianKernelDensity_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_GaussianKernelDensity[] = {
  {"sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_21GaussianKernelDensity_3sample, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_21GaussianKernelDensity_2sample},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_GaussianKernelDensity = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.GaussianKernelDensity", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_GaussianKernelDensity), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_KernelDensity, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n\tA quick way of storing points to represent a Gaussian kernel density in one\n\tdimension. Takes in the points at initialization, and calculates the log of\n\tthe sum of the Gaussian distance of the new point from every other point.\n\t", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_KernelDensity, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_KernelDensity, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_GaussianKernelDensity, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_GaussianKernelDensity, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_UniformKernelDensity __pyx_vtable_11pomegranate_13distributions_UniformKernelDensity;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_UniformKernelDensity(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_UniformKernelDensity *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_KernelDensity(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_UniformKernelDensity *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_UniformKernelDensity;
  if (unlikely(__pyx_pw_11pomegranate_13distributions_20UniformKernelDensity_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_UniformKernelDensity[] = {
  {"sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_20UniformKernelDensity_3sample, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_20UniformKernelDensity_2sample},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_UniformKernelDensity = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.UniformKernelDensity", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_UniformKernelDensity), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_KernelDensity, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n\tA quick way of storing points to represent an Exponential kernel density in\n\tone dimension. Takes in points at initialization, and calculates the log of\n\tthe sum of the Gaussian distances of the new point from every other point.\n\t", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_KernelDensity, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_KernelDensity, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_UniformKernelDensity, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_UniformKernelDensity, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_TriangleKernelDensity __pyx_vtable_11pomegranate_13distributions_TriangleKernelDensity;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_TriangleKernelDensity(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_TriangleKernelDensity *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_KernelDensity(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_TriangleKernelDensity *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_TriangleKernelDensity;
  if (unlikely(__pyx_pw_11pomegranate_13distributions_21TriangleKernelDensity_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_TriangleKernelDensity[] = {
  {"sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_21TriangleKernelDensity_3sample, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_21TriangleKernelDensity_2sample},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_TriangleKernelDensity = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.TriangleKernelDensity", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_TriangleKernelDensity), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_KernelDensity, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n\tA quick way of storing points to represent an Exponential kernel density in\n\tone dimension. Takes in points at initialization, and calculates the log of\n\tthe sum of the Gaussian distances of the new point from every other point.\n\t", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_KernelDensity, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_KernelDensity, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_TriangleKernelDensity, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_TriangleKernelDensity, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_MixtureDistribution __pyx_vtable_11pomegranate_13distributions_MixtureDistribution;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_MixtureDistribution(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_Distribution(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_MixtureDistribution;
  p->distributions = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions_MixtureDistribution(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *p = (struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->distributions);
  Py_CLEAR(p->weights);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_11pomegranate_13distributions_Distribution(o);
}

static int __pyx_tp_traverse_11pomegranate_13distributions_MixtureDistribution(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *p = (struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *)o;
  e = __pyx_tp_traverse_11pomegranate_13distributions_Distribution(o, v, a); if (e) return e;
  if (p->distributions) {
    e = (*v)(((PyObject*)p->distributions), a); if (e) return e;
  }
  if (p->weights) {
    e = (*v)(((PyObject*)p->weights), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions_MixtureDistribution(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *p = (struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution *)o;
  __pyx_tp_clear_11pomegranate_13distributions_Distribution(o);
  tmp = ((PyObject*)p->distributions);
  p->distributions = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->weights);
  p->weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_19MixtureDistribution_parameters(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_19MixtureDistribution_10parameters_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_19MixtureDistribution_parameters(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_19MixtureDistribution_10parameters_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_MixtureDistribution[] = {
  {"sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_3sample, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_19MixtureDistribution_2sample},
  {"from_sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_5from_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_19MixtureDistribution_4from_sample},
  {"summarize", (PyCFunction)__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_7summarize, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_19MixtureDistribution_6summarize},
  {"from_summaries", (PyCFunction)__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_9from_summaries, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_19MixtureDistribution_8from_summaries},
  {"to_json", (PyCFunction)__pyx_pw_11pomegranate_13distributions_19MixtureDistribution_11to_json, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_19MixtureDistribution_10to_json},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11pomegranate_13distributions_MixtureDistribution[] = {
  {(char *)"parameters", __pyx_getprop_11pomegranate_13distributions_19MixtureDistribution_parameters, __pyx_setprop_11pomegranate_13distributions_19MixtureDistribution_parameters, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_MixtureDistribution = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.MixtureDistribution", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_MixtureDistribution), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_MixtureDistribution, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n\tAllows you to create an arbitrary mixture of distributions. There can be\n\tany number of distributions, include any permutation of types of\n\tdistributions. Can also specify weights for the distributions.\n\t", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_MixtureDistribution, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_MixtureDistribution, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_MixtureDistribution, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11pomegranate_13distributions_MixtureDistribution, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_MixtureDistribution, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_MultivariateDistribution __pyx_vtable_11pomegranate_13distributions_MultivariateDistribution;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_MultivariateDistribution(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_MultivariateDistribution *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_Distribution(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_MultivariateDistribution *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_MultivariateDistribution;
  return o;
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_24MultivariateDistribution_d(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_24MultivariateDistribution_1d_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_24MultivariateDistribution_d(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_24MultivariateDistribution_1d_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyGetSetDef __pyx_getsets_11pomegranate_13distributions_MultivariateDistribution[] = {
  {(char *)"d", __pyx_getprop_11pomegranate_13distributions_24MultivariateDistribution_d, __pyx_setprop_11pomegranate_13distributions_24MultivariateDistribution_d, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_MultivariateDistribution = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.MultivariateDistribution", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_MultivariateDistribution), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_Distribution, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n\tAn object to easily identify multivariate distributions such as tables.\n\t", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_Distribution, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_Distribution, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11pomegranate_13distributions_MultivariateDistribution, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_MultivariateDistribution, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_IndependentComponentsDistribution __pyx_vtable_11pomegranate_13distributions_IndependentComponentsDistribution;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_IndependentComponentsDistribution(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_MultivariateDistribution(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_IndependentComponentsDistribution;
  p->distributions = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions_IndependentComponentsDistribution(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *p = (struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->distributions);
  Py_CLEAR(p->weights);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_11pomegranate_13distributions_Distribution(o);
}

static int __pyx_tp_traverse_11pomegranate_13distributions_IndependentComponentsDistribution(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *p = (struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *)o;
  e = __pyx_tp_traverse_11pomegranate_13distributions_Distribution(o, v, a); if (e) return e;
  if (p->distributions) {
    e = (*v)(((PyObject*)p->distributions), a); if (e) return e;
  }
  if (p->weights) {
    e = (*v)(((PyObject*)p->weights), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions_IndependentComponentsDistribution(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *p = (struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution *)o;
  __pyx_tp_clear_11pomegranate_13distributions_Distribution(o);
  tmp = ((PyObject*)p->distributions);
  p->distributions = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->weights);
  p->weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_33IndependentComponentsDistribution_parameters(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_10parameters_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_33IndependentComponentsDistribution_parameters(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_10parameters_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_IndependentComponentsDistribution[] = {
  {"log_probability", (PyCFunction)__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_3log_probability, METH_O, __pyx_doc_11pomegranate_13distributions_33IndependentComponentsDistribution_2log_probability},
  {"sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_5sample, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_33IndependentComponentsDistribution_4sample},
  {"from_sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_7from_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_33IndependentComponentsDistribution_6from_sample},
  {"summarize", (PyCFunction)__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_9summarize, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_33IndependentComponentsDistribution_8summarize},
  {"from_summaries", (PyCFunction)__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_11from_summaries, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_33IndependentComponentsDistribution_10from_summaries},
  {"to_json", (PyCFunction)__pyx_pw_11pomegranate_13distributions_33IndependentComponentsDistribution_13to_json, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_33IndependentComponentsDistribution_12to_json},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11pomegranate_13distributions_IndependentComponentsDistribution[] = {
  {(char *)"parameters", __pyx_getprop_11pomegranate_13distributions_33IndependentComponentsDistribution_parameters, __pyx_setprop_11pomegranate_13distributions_33IndependentComponentsDistribution_parameters, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_IndependentComponentsDistribution = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.IndependentComponentsDistribution", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_IndependentComponentsDistribution), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_IndependentComponentsDistribution, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n\tAllows you to create a multivariate distribution, where each distribution\n\tis independent of the others. Distributions can be any type, such as\n\thaving an exponential represent the duration of an event, and a normal\n\trepresent the mean of that event. Observations must now be tuples of\n\ta length equal to the number of distributions passed in.\n\n\ts1 = IndependentComponentsDistribution([ ExponentialDistribution( 0.1 ), \n\t\t\t\t\t\t\t\t\tNormalDistribution( 5, 2 ) ])\n\ts1.log_probability( (5, 2 ) )\n\t", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_IndependentComponentsDistribution, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_IndependentComponentsDistribution, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_IndependentComponentsDistribution, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11pomegranate_13distributions_IndependentComponentsDistribution, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_IndependentComponentsDistribution, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_MultivariateGaussianDistribution __pyx_vtable_11pomegranate_13distributions_MultivariateGaussianDistribution;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_MultivariateGaussianDistribution(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_MultivariateDistribution(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_MultivariateGaussianDistribution;
  p->mu = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->cov = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->inv_cov_ndarray = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions_MultivariateGaussianDistribution(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *p = (struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_3__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->mu);
  Py_CLEAR(p->cov);
  Py_CLEAR(p->inv_cov_ndarray);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_11pomegranate_13distributions_Distribution(o);
}

static int __pyx_tp_traverse_11pomegranate_13distributions_MultivariateGaussianDistribution(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *p = (struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)o;
  e = __pyx_tp_traverse_11pomegranate_13distributions_Distribution(o, v, a); if (e) return e;
  if (p->mu) {
    e = (*v)(((PyObject*)p->mu), a); if (e) return e;
  }
  if (p->cov) {
    e = (*v)(((PyObject*)p->cov), a); if (e) return e;
  }
  if (p->inv_cov_ndarray) {
    e = (*v)(((PyObject*)p->inv_cov_ndarray), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions_MultivariateGaussianDistribution(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *p = (struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *)o;
  __pyx_tp_clear_11pomegranate_13distributions_Distribution(o);
  tmp = ((PyObject*)p->mu);
  p->mu = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->cov);
  p->cov = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->inv_cov_ndarray);
  p->inv_cov_ndarray = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_32MultivariateGaussianDistribution_parameters(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_10parameters_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_32MultivariateGaussianDistribution_parameters(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_10parameters_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_32MultivariateGaussianDistribution_mu(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_32MultivariateGaussianDistribution_mu(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu_3__set__(o, v);
  }
  else {
    return __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_2mu_5__del__(o);
  }
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_32MultivariateGaussianDistribution_cov(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_32MultivariateGaussianDistribution_cov(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov_3__set__(o, v);
  }
  else {
    return __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_3cov_5__del__(o);
  }
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_32MultivariateGaussianDistribution_inv_cov_ndarray(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_32MultivariateGaussianDistribution_inv_cov_ndarray(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray_3__set__(o, v);
  }
  else {
    return __pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_15inv_cov_ndarray_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_MultivariateGaussianDistribution[] = {
  {"log_probability", (PyCFunction)__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_5log_probability, METH_O, __pyx_doc_11pomegranate_13distributions_32MultivariateGaussianDistribution_4log_probability},
  {"sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_7sample, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_32MultivariateGaussianDistribution_6sample},
  {"from_sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_9from_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_32MultivariateGaussianDistribution_8from_sample},
  {"summarize", (PyCFunction)__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_11summarize, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_32MultivariateGaussianDistribution_10summarize},
  {"from_summaries", (PyCFunction)__pyx_pw_11pomegranate_13distributions_32MultivariateGaussianDistribution_13from_summaries, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_32MultivariateGaussianDistribution_12from_summaries},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11pomegranate_13distributions_MultivariateGaussianDistribution[] = {
  {(char *)"parameters", __pyx_getprop_11pomegranate_13distributions_32MultivariateGaussianDistribution_parameters, __pyx_setprop_11pomegranate_13distributions_32MultivariateGaussianDistribution_parameters, 0, 0},
  {(char *)"mu", __pyx_getprop_11pomegranate_13distributions_32MultivariateGaussianDistribution_mu, __pyx_setprop_11pomegranate_13distributions_32MultivariateGaussianDistribution_mu, 0, 0},
  {(char *)"cov", __pyx_getprop_11pomegranate_13distributions_32MultivariateGaussianDistribution_cov, __pyx_setprop_11pomegranate_13distributions_32MultivariateGaussianDistribution_cov, 0, 0},
  {(char *)"inv_cov_ndarray", __pyx_getprop_11pomegranate_13distributions_32MultivariateGaussianDistribution_inv_cov_ndarray, __pyx_setprop_11pomegranate_13distributions_32MultivariateGaussianDistribution_inv_cov_ndarray, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_MultivariateGaussianDistribution = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.MultivariateGaussianDistribution", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_MultivariateGaussianDistribution, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_3__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_MultivariateGaussianDistribution, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_MultivariateGaussianDistribution, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_MultivariateGaussianDistribution, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11pomegranate_13distributions_MultivariateGaussianDistribution, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_MultivariateGaussianDistribution, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_ConditionalProbabilityTable __pyx_vtable_11pomegranate_13distributions_ConditionalProbabilityTable;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_ConditionalProbabilityTable(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_MultivariateDistribution(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_ConditionalProbabilityTable;
  p->parameters = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions_ConditionalProbabilityTable(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *p = (struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->parameters);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_11pomegranate_13distributions_Distribution(o);
}

static int __pyx_tp_traverse_11pomegranate_13distributions_ConditionalProbabilityTable(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *p = (struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *)o;
  e = __pyx_tp_traverse_11pomegranate_13distributions_Distribution(o, v, a); if (e) return e;
  if (p->parameters) {
    e = (*v)(p->parameters, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions_ConditionalProbabilityTable(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *p = (struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *)o;
  __pyx_tp_clear_11pomegranate_13distributions_Distribution(o);
  tmp = ((PyObject*)p->parameters);
  p->parameters = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_27ConditionalProbabilityTable_parameters(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_27ConditionalProbabilityTable_parameters(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters_3__set__(o, v);
  }
  else {
    return __pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_10parameters_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_ConditionalProbabilityTable[] = {
  {"keys", (PyCFunction)__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_7keys, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_27ConditionalProbabilityTable_6keys},
  {"log_probability", (PyCFunction)__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_9log_probability, METH_O, __pyx_doc_11pomegranate_13distributions_27ConditionalProbabilityTable_8log_probability},
  {"joint", (PyCFunction)__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_11joint, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_27ConditionalProbabilityTable_10joint},
  {"marginal", (PyCFunction)__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_13marginal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_27ConditionalProbabilityTable_12marginal},
  {"from_sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_15from_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_27ConditionalProbabilityTable_14from_sample},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11pomegranate_13distributions_ConditionalProbabilityTable[] = {
  {(char *)"parameters", __pyx_getprop_11pomegranate_13distributions_27ConditionalProbabilityTable_parameters, __pyx_setprop_11pomegranate_13distributions_27ConditionalProbabilityTable_parameters, 0, 0},
  {0, 0, 0, 0, 0}
};

static PySequenceMethods __pyx_tp_as_sequence_ConditionalProbabilityTable = {
  __pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_5__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_ConditionalProbabilityTable = {
  __pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_5__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_ConditionalProbabilityTable = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.ConditionalProbabilityTable", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_ConditionalProbabilityTable, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  &__pyx_tp_as_sequence_ConditionalProbabilityTable, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ConditionalProbabilityTable, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_3__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n\tA conditional probability table, which is dependent on values from at\n\tleast one previous distribution but up to as many as you want to\n\tencode for.\n\t", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_ConditionalProbabilityTable, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_ConditionalProbabilityTable, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_ConditionalProbabilityTable, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11pomegranate_13distributions_ConditionalProbabilityTable, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_11pomegranate_13distributions_27ConditionalProbabilityTable_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_ConditionalProbabilityTable, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_11pomegranate_13distributions_JointProbabilityTable __pyx_vtable_11pomegranate_13distributions_JointProbabilityTable;

static PyObject *__pyx_tp_new_11pomegranate_13distributions_JointProbabilityTable(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *p;
  PyObject *o = __pyx_tp_new_11pomegranate_13distributions_MultivariateDistribution(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_11pomegranate_13distributions_Distribution*)__pyx_vtabptr_11pomegranate_13distributions_JointProbabilityTable;
  p->parameters = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions_JointProbabilityTable(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *p = (struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->parameters);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_11pomegranate_13distributions_Distribution(o);
}

static int __pyx_tp_traverse_11pomegranate_13distributions_JointProbabilityTable(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *p = (struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *)o;
  e = __pyx_tp_traverse_11pomegranate_13distributions_Distribution(o, v, a); if (e) return e;
  if (p->parameters) {
    e = (*v)(p->parameters, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions_JointProbabilityTable(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *p = (struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *)o;
  __pyx_tp_clear_11pomegranate_13distributions_Distribution(o);
  tmp = ((PyObject*)p->parameters);
  p->parameters = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_11pomegranate_13distributions_21JointProbabilityTable_parameters(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_10parameters_1__get__(o);
}

static int __pyx_setprop_11pomegranate_13distributions_21JointProbabilityTable_parameters(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_10parameters_3__set__(o, v);
  }
  else {
    return __pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_10parameters_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_11pomegranate_13distributions_JointProbabilityTable[] = {
  {"keys", (PyCFunction)__pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_7keys, METH_NOARGS, __pyx_doc_11pomegranate_13distributions_21JointProbabilityTable_6keys},
  {"log_probability", (PyCFunction)__pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_9log_probability, METH_O, __pyx_doc_11pomegranate_13distributions_21JointProbabilityTable_8log_probability},
  {"marginal", (PyCFunction)__pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_11marginal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_21JointProbabilityTable_10marginal},
  {"from_sample", (PyCFunction)__pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_13from_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11pomegranate_13distributions_21JointProbabilityTable_12from_sample},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_11pomegranate_13distributions_JointProbabilityTable[] = {
  {(char *)"parameters", __pyx_getprop_11pomegranate_13distributions_21JointProbabilityTable_parameters, __pyx_setprop_11pomegranate_13distributions_21JointProbabilityTable_parameters, 0, 0},
  {0, 0, 0, 0, 0}
};

static PySequenceMethods __pyx_tp_as_sequence_JointProbabilityTable = {
  __pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_5__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_JointProbabilityTable = {
  __pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_5__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_11pomegranate_13distributions_JointProbabilityTable = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.JointProbabilityTable", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions_JointProbabilityTable, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_11pomegranate_13distributions_12Distribution_5__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  &__pyx_tp_as_sequence_JointProbabilityTable, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_JointProbabilityTable, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_3__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n\tA joint probability table. The primary difference between this and the\n\tconditional table is that the final column sums to one here. The joint\n\ttable can be thought of as the conditional probability table normalized\n\tby the marginals of each parent.\n\t", /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions_JointProbabilityTable, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions_JointProbabilityTable, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_11pomegranate_13distributions_JointProbabilityTable, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_11pomegranate_13distributions_JointProbabilityTable, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_11pomegranate_13distributions_21JointProbabilityTable_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions_JointProbabilityTable, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__ *__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct____str__[8];
static int __pyx_freecount_11pomegranate_13distributions___pyx_scope_struct____str__ = 0;

static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct____str__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct____str__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__)))) {
    o = (PyObject*)__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct____str__[--__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct____str__];
    memset(o, 0, sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct____str__(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__ *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_keys);
  Py_CLEAR(p->__pyx_v_values);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct____str__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__)))) {
    __pyx_freelist_11pomegranate_13distributions___pyx_scope_struct____str__[__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct____str__++] = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct____str__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__ *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__ *)o;
  if (p->__pyx_v_keys) {
    e = (*v)(p->__pyx_v_keys, a); if (e) return e;
  }
  if (p->__pyx_v_values) {
    e = (*v)(p->__pyx_v_values, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct____str__(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__ *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__ *)o;
  tmp = ((PyObject*)p->__pyx_v_keys);
  p->__pyx_v_keys = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_values);
  p->__pyx_v_values = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_11pomegranate_13distributions___pyx_scope_struct____str__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.__pyx_scope_struct____str__", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct____str__, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct____str__, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct____str__, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct____str__, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr *__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_1_genexpr[8];
static int __pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_1_genexpr = 0;

static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_1_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_1_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr)))) {
    o = (PyObject*)__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_1_genexpr[--__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_1_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_1_genexpr(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_idx);
  Py_CLEAR(p->__pyx_v_key);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_1_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr)))) {
    __pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_1_genexpr[__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_1_genexpr++] = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_1_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_idx) {
    e = (*v)(p->__pyx_v_idx, a); if (e) return e;
  }
  if (p->__pyx_v_key) {
    e = (*v)(p->__pyx_v_key, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_1_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct____str__ *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_idx);
  p->__pyx_v_idx = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_key);
  p->__pyx_v_key = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_t_0);
  p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_11pomegranate_13distributions___pyx_scope_struct_1_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.__pyx_scope_struct_1_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_1_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_1_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_1_genexpr, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_1_genexpr, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_1_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys *__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_2_keys[8];
static int __pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_2_keys = 0;

static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_2_keys(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_2_keys > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys)))) {
    o = (PyObject*)__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_2_keys[--__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_2_keys];
    memset(o, 0, sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_2_keys(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_2_keys < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys)))) {
    __pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_2_keys[__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_2_keys++] = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_2_keys(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_2_keys(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_11pomegranate_13distributions_ConditionalProbabilityTable *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_11pomegranate_13distributions___pyx_scope_struct_2_keys = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.__pyx_scope_struct_2_keys", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_2_keys, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_2_keys, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_2_keys, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_2_keys, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr *__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_3_genexpr[8];
static int __pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_3_genexpr = 0;

static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_3_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_3_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr)))) {
    o = (PyObject*)__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_3_genexpr[--__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_3_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_3_genexpr(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_row);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_3_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr)))) {
    __pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_3_genexpr[__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_3_genexpr++] = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_3_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_row) {
    e = (*v)(p->__pyx_v_row, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_3_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_2_keys *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_row);
  p->__pyx_v_row = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_11pomegranate_13distributions___pyx_scope_struct_3_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.__pyx_scope_struct_3_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_3_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_3_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_3_genexpr, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_3_genexpr, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_3_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint *__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_4_joint[8];
static int __pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_4_joint = 0;

static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_4_joint(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_4_joint > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint)))) {
    o = (PyObject*)__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_4_joint[--__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_4_joint];
    memset(o, 0, sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_4_joint(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_table);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_4_joint < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint)))) {
    __pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_4_joint[__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_4_joint++] = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_4_joint(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint *)o;
  if (p->__pyx_v_table) {
    e = (*v)(p->__pyx_v_table, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_4_joint(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint *)o;
  tmp = ((PyObject*)p->__pyx_v_table);
  p->__pyx_v_table = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_11pomegranate_13distributions___pyx_scope_struct_4_joint = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.__pyx_scope_struct_4_joint", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_4_joint, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_4_joint, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_4_joint, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_4_joint, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr *__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_5_genexpr[8];
static int __pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_5_genexpr = 0;

static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_5_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_5_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr)))) {
    o = (PyObject*)__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_5_genexpr[--__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_5_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_5_genexpr(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_row);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_5_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr)))) {
    __pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_5_genexpr[__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_5_genexpr++] = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_5_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_row) {
    e = (*v)(p->__pyx_v_row, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_5_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_4_joint *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_row);
  p->__pyx_v_row = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_t_0);
  p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_11pomegranate_13distributions___pyx_scope_struct_5_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.__pyx_scope_struct_5_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_5_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_5_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_5_genexpr, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_5_genexpr, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_5_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__ *__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_6___str__[8];
static int __pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_6___str__ = 0;

static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_6___str__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_6___str__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__)))) {
    o = (PyObject*)__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_6___str__[--__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_6___str__];
    memset(o, 0, sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_6___str__(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__ *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_keys);
  Py_CLEAR(p->__pyx_v_values);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_6___str__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__)))) {
    __pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_6___str__[__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_6___str__++] = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_6___str__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__ *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__ *)o;
  if (p->__pyx_v_keys) {
    e = (*v)(p->__pyx_v_keys, a); if (e) return e;
  }
  if (p->__pyx_v_values) {
    e = (*v)(p->__pyx_v_values, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_6___str__(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__ *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__ *)o;
  tmp = ((PyObject*)p->__pyx_v_keys);
  p->__pyx_v_keys = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_values);
  p->__pyx_v_values = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_11pomegranate_13distributions___pyx_scope_struct_6___str__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.__pyx_scope_struct_6___str__", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_6___str__, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_6___str__, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_6___str__, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_6___str__, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr *__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_7_genexpr[8];
static int __pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_7_genexpr = 0;

static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_7_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_7_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr)))) {
    o = (PyObject*)__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_7_genexpr[--__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_7_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_7_genexpr(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_idx);
  Py_CLEAR(p->__pyx_v_key);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_7_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr)))) {
    __pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_7_genexpr[__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_7_genexpr++] = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_7_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_idx) {
    e = (*v)(p->__pyx_v_idx, a); if (e) return e;
  }
  if (p->__pyx_v_key) {
    e = (*v)(p->__pyx_v_key, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_7_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_6___str__ *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_idx);
  p->__pyx_v_idx = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_key);
  p->__pyx_v_key = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_t_0);
  p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_11pomegranate_13distributions___pyx_scope_struct_7_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.__pyx_scope_struct_7_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_7_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_7_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_7_genexpr, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_7_genexpr, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_7_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys *__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_8_keys[8];
static int __pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_8_keys = 0;

static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_8_keys(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_8_keys > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys)))) {
    o = (PyObject*)__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_8_keys[--__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_8_keys];
    memset(o, 0, sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_8_keys(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_8_keys < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys)))) {
    __pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_8_keys[__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_8_keys++] = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_8_keys(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_8_keys(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_11pomegranate_13distributions_JointProbabilityTable *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_11pomegranate_13distributions___pyx_scope_struct_8_keys = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.__pyx_scope_struct_8_keys", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_8_keys, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_8_keys, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_8_keys, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_8_keys, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr *__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_9_genexpr[8];
static int __pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_9_genexpr = 0;

static PyObject *__pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_9_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_9_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr)))) {
    o = (PyObject*)__pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_9_genexpr[--__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_9_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_9_genexpr(PyObject *o) {
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_row);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_9_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr)))) {
    __pyx_freelist_11pomegranate_13distributions___pyx_scope_struct_9_genexpr[__pyx_freecount_11pomegranate_13distributions___pyx_scope_struct_9_genexpr++] = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_9_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_row) {
    e = (*v)(p->__pyx_v_row, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_9_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr *p = (struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_8_keys *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_row);
  p->__pyx_v_row = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_11pomegranate_13distributions___pyx_scope_struct_9_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pomegranate.distributions.__pyx_scope_struct_9_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_11pomegranate_13distributions___pyx_scope_struct_9_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_11pomegranate_13distributions___pyx_scope_struct_9_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_11pomegranate_13distributions___pyx_scope_struct_9_genexpr, /*tp_traverse*/
  __pyx_tp_clear_11pomegranate_13distributions___pyx_scope_struct_9_genexpr, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_11pomegranate_13distributions___pyx_scope_struct_9_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
  #if PY_VERSION_HEX < 0x03020000
    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  #else
    PyModuleDef_HEAD_INIT,
  #endif
    "distributions",
    0, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 1},
  {&__pyx_n_s_BetaDistribution, __pyx_k_BetaDistribution, sizeof(__pyx_k_BetaDistribution), 0, 0, 1, 1},
  {&__pyx_n_s_ConditionalProbabilityTable, __pyx_k_ConditionalProbabilityTable, sizeof(__pyx_k_ConditionalProbabilityTable), 0, 0, 1, 1},
  {&__pyx_n_s_DiscreteDistribution, __pyx_k_DiscreteDistribution, sizeof(__pyx_k_DiscreteDistribution), 0, 0, 1, 1},
  {&__pyx_n_s_Distribution, __pyx_k_Distribution, sizeof(__pyx_k_Distribution), 0, 0, 1, 1},
  {&__pyx_kp_s_Distribution_object_attempting_t, __pyx_k_Distribution_object_attempting_t, sizeof(__pyx_k_Distribution_object_attempting_t), 0, 0, 1, 0},
  {&__pyx_n_s_ExponentialDistribution, __pyx_k_ExponentialDistribution, sizeof(__pyx_k_ExponentialDistribution), 0, 0, 1, 1},
  {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0},
  {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0},
  {&__pyx_n_s_GammaDistribution, __pyx_k_GammaDistribution, sizeof(__pyx_k_GammaDistribution), 0, 0, 1, 1},
  {&__pyx_n_s_GaussianKernelDensity, __pyx_k_GaussianKernelDensity, sizeof(__pyx_k_GaussianKernelDensity), 0, 0, 1, 1},
  {&__pyx_n_s_IndependentComponentsDistributio, __pyx_k_IndependentComponentsDistributio, sizeof(__pyx_k_IndependentComponentsDistributio), 0, 0, 1, 1},
  {&__pyx_n_s_JointProbabilityTable, __pyx_k_JointProbabilityTable, sizeof(__pyx_k_JointProbabilityTable), 0, 0, 1, 1},
  {&__pyx_n_s_KernelDensity, __pyx_k_KernelDensity, sizeof(__pyx_k_KernelDensity), 0, 0, 1, 1},
  {&__pyx_n_s_LambdaDistribution, __pyx_k_LambdaDistribution, sizeof(__pyx_k_LambdaDistribution), 0, 0, 1, 1},
  {&__pyx_n_s_LogNormalDistribution, __pyx_k_LogNormalDistribution, sizeof(__pyx_k_LogNormalDistribution), 0, 0, 1, 1},
  {&__pyx_n_s_MixtureDistribution, __pyx_k_MixtureDistribution, sizeof(__pyx_k_MixtureDistribution), 0, 0, 1, 1},
  {&__pyx_n_s_MultivariateGaussianDistribution, __pyx_k_MultivariateGaussianDistribution, sizeof(__pyx_k_MultivariateGaussianDistribution), 0, 0, 1, 1},
  {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0},
  {&__pyx_n_s_NormalDistribution, __pyx_k_NormalDistribution, sizeof(__pyx_k_NormalDistribution), 0, 0, 1, 1},
  {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1},
  {&__pyx_n_s_OrderedDict, __pyx_k_OrderedDict, sizeof(__pyx_k_OrderedDict), 0, 0, 1, 1},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_n_s_SyntaxError, __pyx_k_SyntaxError, sizeof(__pyx_k_SyntaxError), 0, 0, 1, 1},
  {&__pyx_n_s_TriangleKernelDensity, __pyx_k_TriangleKernelDensity, sizeof(__pyx_k_TriangleKernelDensity), 0, 0, 1, 1},
  {&__pyx_n_s_UniformDistribution, __pyx_k_UniformDistribution, sizeof(__pyx_k_UniformDistribution), 0, 0, 1, 1},
  {&__pyx_n_s_UniformKernelDensity, __pyx_k_UniformKernelDensity, sizeof(__pyx_k_UniformKernelDensity), 0, 0, 1, 1},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0},
  {&__pyx_kp_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 0},
  {&__pyx_kp_s__30, __pyx_k__30, sizeof(__pyx_k__30), 0, 0, 1, 0},
  {&__pyx_kp_s__31, __pyx_k__31, sizeof(__pyx_k__31), 0, 0, 1, 0},
  {&__pyx_kp_s__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 0, 1, 0},
  {&__pyx_n_s_alpha, __pyx_k_alpha, sizeof(__pyx_k_alpha), 0, 0, 1, 1},
  {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  {&__pyx_n_s_array, __pyx_k_array, sizeof(__pyx_k_array), 0, 0, 1, 1},
  {&__pyx_n_s_asarray, __pyx_k_asarray, sizeof(__pyx_k_asarray), 0, 0, 1, 1},
  {&__pyx_n_s_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 0, 0, 1, 1},
  {&__pyx_n_s_average, __pyx_k_average, sizeof(__pyx_k_average), 0, 0, 1, 1},
  {&__pyx_n_s_axis, __pyx_k_axis, sizeof(__pyx_k_axis), 0, 0, 1, 1},
  {&__pyx_n_s_bandwidth, __pyx_k_bandwidth, sizeof(__pyx_k_bandwidth), 0, 0, 1, 1},
  {&__pyx_n_s_beta, __pyx_k_beta, sizeof(__pyx_k_beta), 0, 0, 1, 1},
  {&__pyx_n_s_betavariate, __pyx_k_betavariate, sizeof(__pyx_k_betavariate), 0, 0, 1, 1},
  {&__pyx_n_s_characters, __pyx_k_characters, sizeof(__pyx_k_characters), 0, 0, 1, 1},
  {&__pyx_n_s_choice, __pyx_k_choice, sizeof(__pyx_k_choice), 0, 0, 1, 1},
  {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
  {&__pyx_n_s_class_2, __pyx_k_class_2, sizeof(__pyx_k_class_2), 0, 0, 1, 1},
  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_n_s_cls, __pyx_k_cls, sizeof(__pyx_k_cls), 0, 0, 1, 1},
  {&__pyx_n_s_collections, __pyx_k_collections, sizeof(__pyx_k_collections), 0, 0, 1, 1},
  {&__pyx_n_s_concatenate, __pyx_k_concatenate, sizeof(__pyx_k_concatenate), 0, 0, 1, 1},
  {&__pyx_kp_s_cov_is_not_a_square_matrix_dimen, __pyx_k_cov_is_not_a_square_matrix_dimen, sizeof(__pyx_k_cov_is_not_a_square_matrix_dimen), 0, 0, 1, 0},
  {&__pyx_n_s_covariance, __pyx_k_covariance, sizeof(__pyx_k_covariance), 0, 0, 1, 1},
  {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1},
  {&__pyx_n_s_det, __pyx_k_det, sizeof(__pyx_k_det), 0, 0, 1, 1},
  {&__pyx_n_s_dist, __pyx_k_dist, sizeof(__pyx_k_dist), 0, 0, 1, 1},
  {&__pyx_n_s_distributions, __pyx_k_distributions, sizeof(__pyx_k_distributions), 0, 0, 1, 1},
  {&__pyx_n_s_dot, __pyx_k_dot, sizeof(__pyx_k_dot), 0, 0, 1, 1},
  {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_dumps, __pyx_k_dumps, sizeof(__pyx_k_dumps), 0, 0, 1, 1},
  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1},
  {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  {&__pyx_n_s_epsilon, __pyx_k_epsilon, sizeof(__pyx_k_epsilon), 0, 0, 1, 1},
  {&__pyx_n_s_eval, __pyx_k_eval, sizeof(__pyx_k_eval), 0, 0, 1, 1},
  {&__pyx_n_s_exp, __pyx_k_exp, sizeof(__pyx_k_exp), 0, 0, 1, 1},
  {&__pyx_n_s_expovariate, __pyx_k_expovariate, sizeof(__pyx_k_expovariate), 0, 0, 1, 1},
  {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1},
  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_n_s_from_json, __pyx_k_from_json, sizeof(__pyx_k_from_json), 0, 0, 1, 1},
  {&__pyx_n_s_from_sample, __pyx_k_from_sample, sizeof(__pyx_k_from_sample), 0, 0, 1, 1},
  {&__pyx_n_s_from_summaries, __pyx_k_from_summaries, sizeof(__pyx_k_from_summaries), 0, 0, 1, 1},
  {&__pyx_n_s_frozen, __pyx_k_frozen, sizeof(__pyx_k_frozen), 0, 0, 1, 1},
  {&__pyx_kp_s_frozen_2, __pyx_k_frozen_2, sizeof(__pyx_k_frozen_2), 0, 0, 1, 0},
  {&__pyx_n_s_gammavariate, __pyx_k_gammavariate, sizeof(__pyx_k_gammavariate), 0, 0, 1, 1},
  {&__pyx_n_s_gauss, __pyx_k_gauss, sizeof(__pyx_k_gauss), 0, 0, 1, 1},
  {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  {&__pyx_n_s_hist, __pyx_k_hist, sizeof(__pyx_k_hist), 0, 0, 1, 1},
  {&__pyx_kp_s_home_jmschr_Desktop_pomegranate, __pyx_k_home_jmschr_Desktop_pomegranate, sizeof(__pyx_k_home_jmschr_Desktop_pomegranate), 0, 0, 1, 0},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_indent, __pyx_k_indent, sizeof(__pyx_k_indent), 0, 0, 1, 1},
  {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1},
  {&__pyx_n_s_inertia, __pyx_k_inertia, sizeof(__pyx_k_inertia), 0, 0, 1, 1},
  {&__pyx_n_s_inf, __pyx_k_inf, sizeof(__pyx_k_inf), 0, 0, 1, 1},
  {&__pyx_n_s_inv, __pyx_k_inv, sizeof(__pyx_k_inv), 0, 0, 1, 1},
  {&__pyx_n_s_it, __pyx_k_it, sizeof(__pyx_k_it), 0, 0, 1, 1},
  {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
  {&__pyx_n_s_iteration_limit, __pyx_k_iteration_limit, sizeof(__pyx_k_iteration_limit), 0, 0, 1, 1},
  {&__pyx_n_s_itertools, __pyx_k_itertools, sizeof(__pyx_k_itertools), 0, 0, 1, 1},
  {&__pyx_n_s_izip, __pyx_k_izip, sizeof(__pyx_k_izip), 0, 0, 1, 1},
  {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
  {&__pyx_n_s_joint, __pyx_k_joint, sizeof(__pyx_k_joint), 0, 0, 1, 1},
  {&__pyx_n_s_joint_locals_genexpr, __pyx_k_joint_locals_genexpr, sizeof(__pyx_k_joint_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_json, __pyx_k_json, sizeof(__pyx_k_json), 0, 0, 1, 1},
  {&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1},
  {&__pyx_n_s_keys_locals_genexpr, __pyx_k_keys_locals_genexpr, sizeof(__pyx_k_keys_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_lambda_funct, __pyx_k_lambda_funct, sizeof(__pyx_k_lambda_funct), 0, 0, 1, 1},
  {&__pyx_n_s_linalg, __pyx_k_linalg, sizeof(__pyx_k_linalg), 0, 0, 1, 1},
  {&__pyx_n_s_loads, __pyx_k_loads, sizeof(__pyx_k_loads), 0, 0, 1, 1},
  {&__pyx_n_s_log, __pyx_k_log, sizeof(__pyx_k_log), 0, 0, 1, 1},
  {&__pyx_n_s_log_probability, __pyx_k_log_probability, sizeof(__pyx_k_log_probability), 0, 0, 1, 1},
  {&__pyx_n_s_lognormal, __pyx_k_lognormal, sizeof(__pyx_k_lognormal), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_map, __pyx_k_map, sizeof(__pyx_k_map), 0, 0, 1, 1},
  {&__pyx_n_s_marginal, __pyx_k_marginal, sizeof(__pyx_k_marginal), 0, 0, 1, 1},
  {&__pyx_n_s_matplotlib_pyplot, __pyx_k_matplotlib_pyplot, sizeof(__pyx_k_matplotlib_pyplot), 0, 0, 1, 1},
  {&__pyx_n_s_mean, __pyx_k_mean, sizeof(__pyx_k_mean), 0, 0, 1, 1},
  {&__pyx_n_s_means, __pyx_k_means, sizeof(__pyx_k_means), 0, 0, 1, 1},
  {&__pyx_n_s_min_std, __pyx_k_min_std, sizeof(__pyx_k_min_std), 0, 0, 1, 1},
  {&__pyx_n_s_mu, __pyx_k_mu, sizeof(__pyx_k_mu), 0, 0, 1, 1},
  {&__pyx_kp_s_mu_shape_is_while_cov_shape_is, __pyx_k_mu_shape_is_while_cov_shape_is, sizeof(__pyx_k_mu_shape_is_while_cov_shape_is), 0, 0, 1, 0},
  {&__pyx_n_s_multivariate_normal, __pyx_k_multivariate_normal, sizeof(__pyx_k_multivariate_normal), 0, 0, 1, 1},
  {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0},
  {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0},
  {&__pyx_n_s_neighbor_values, __pyx_k_neighbor_values, sizeof(__pyx_k_neighbor_values), 0, 0, 1, 1},
  {&__pyx_n_s_neighbors, __pyx_k_neighbors, sizeof(__pyx_k_neighbors), 0, 0, 1, 1},
  {&__pyx_n_s_normalvariate, __pyx_k_normalvariate, sizeof(__pyx_k_normalvariate), 0, 0, 1, 1},
  {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
  {&__pyx_n_s_ones, __pyx_k_ones, sizeof(__pyx_k_ones), 0, 0, 1, 1},
  {&__pyx_n_s_ones_like, __pyx_k_ones_like, sizeof(__pyx_k_ones_like), 0, 0, 1, 1},
  {&__pyx_n_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 1},
  {&__pyx_n_s_parameters, __pyx_k_parameters, sizeof(__pyx_k_parameters), 0, 0, 1, 1},
  {&__pyx_n_s_parents, __pyx_k_parents, sizeof(__pyx_k_parents), 0, 0, 1, 1},
  {&__pyx_n_s_points, __pyx_k_points, sizeof(__pyx_k_points), 0, 0, 1, 1},
  {&__pyx_n_s_polygamma, __pyx_k_polygamma, sizeof(__pyx_k_polygamma), 0, 0, 1, 1},
  {&__pyx_n_s_pomegranate_distributions, __pyx_k_pomegranate_distributions, sizeof(__pyx_k_pomegranate_distributions), 0, 0, 1, 1},
  {&__pyx_n_s_pseudocount, __pyx_k_pseudocount, sizeof(__pyx_k_pseudocount), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_s_random, __pyx_k_random, sizeof(__pyx_k_random), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_rate, __pyx_k_rate, sizeof(__pyx_k_rate), 0, 0, 1, 1},
  {&__pyx_n_s_round, __pyx_k_round, sizeof(__pyx_k_round), 0, 0, 1, 1},
  {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1},
  {&__pyx_n_s_sample, __pyx_k_sample, sizeof(__pyx_k_sample), 0, 0, 1, 1},
  {&__pyx_n_s_scipy, __pyx_k_scipy, sizeof(__pyx_k_scipy), 0, 0, 1, 1},
  {&__pyx_n_s_scipy_special, __pyx_k_scipy_special, sizeof(__pyx_k_scipy_special), 0, 0, 1, 1},
  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  {&__pyx_n_s_separators, __pyx_k_separators, sizeof(__pyx_k_separators), 0, 0, 1, 1},
  {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
  {&__pyx_n_s_sigma, __pyx_k_sigma, sizeof(__pyx_k_sigma), 0, 0, 1, 1},
  {&__pyx_n_s_special, __pyx_k_special, sizeof(__pyx_k_special), 0, 0, 1, 1},
  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
  {&__pyx_n_s_std, __pyx_k_std, sizeof(__pyx_k_std), 0, 0, 1, 1},
  {&__pyx_n_s_str___locals_genexpr, __pyx_k_str___locals_genexpr, sizeof(__pyx_k_str___locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 0, 0, 1, 1},
  {&__pyx_n_s_summarize, __pyx_k_summarize, sizeof(__pyx_k_summarize), 0, 0, 1, 1},
  {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
  {&__pyx_n_s_table, __pyx_k_table, sizeof(__pyx_k_table), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  {&__pyx_n_s_to_json, __pyx_k_to_json, sizeof(__pyx_k_to_json), 0, 0, 1, 1},
  {&__pyx_n_s_to_return, __pyx_k_to_return, sizeof(__pyx_k_to_return), 0, 0, 1, 1},
  {&__pyx_n_s_tolist, __pyx_k_tolist, sizeof(__pyx_k_tolist), 0, 0, 1, 1},
  {&__pyx_n_s_train, __pyx_k_train, sizeof(__pyx_k_train), 0, 0, 1, 1},
  {&__pyx_n_s_triangular, __pyx_k_triangular, sizeof(__pyx_k_triangular), 0, 0, 1, 1},
  {&__pyx_n_s_uniform, __pyx_k_uniform, sizeof(__pyx_k_uniform), 0, 0, 1, 1},
  {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0},
  {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1},
  {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1},
  {&__pyx_n_s_weight_set, __pyx_k_weight_set, sizeof(__pyx_k_weight_set), 0, 0, 1, 1},
  {&__pyx_n_s_weights, __pyx_k_weights, sizeof(__pyx_k_weights), 0, 0, 1, 1},
  {&__pyx_n_s_wrt, __pyx_k_wrt, sizeof(__pyx_k_wrt), 0, 0, 1, 1},
  {&__pyx_n_s_xrange, __pyx_k_xrange, sizeof(__pyx_k_xrange), 0, 0, 1, 1},
  {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1},
  {&__pyx_n_s_zeros_like, __pyx_k_zeros_like, sizeof(__pyx_k_zeros_like), 0, 0, 1, 1},
  {&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_SyntaxError = __Pyx_GetBuiltinName(__pyx_n_s_SyntaxError); if (!__pyx_builtin_SyntaxError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_eval = __Pyx_GetBuiltinName(__pyx_n_s_eval); if (!__pyx_builtin_eval) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_map = __Pyx_GetBuiltinName(__pyx_n_s_map); if (!__pyx_builtin_map) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_round = __Pyx_GetBuiltinName(__pyx_n_s_round); if (!__pyx_builtin_round) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_sum = __Pyx_GetBuiltinName(__pyx_n_s_sum); if (!__pyx_builtin_sum) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "pomegranate/distributions.pyx":212
 * 								'parameters' : self.parameters,
 * 								'frozen' : self.frozen
 * 						   }, separators=(',', ' : ' ), indent=4 )             # <<<<<<<<<<<<<<
 * 
 * 	@classmethod
 */
  __pyx_tuple__4 = PyTuple_Pack(2, __pyx_kp_s__2, __pyx_kp_s__3); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "pomegranate/distributions.pyx":221
 * 
 * 		if ' ' in d['class'] or 'Distribution' not in d['class']:
 * 			raise SyntaxError( "Distribution object attempting to read invalid object." )             # <<<<<<<<<<<<<<
 * 
 * 		if d['name'] == 'IndependentComponentsDistribution':
 */
  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_Distribution_object_attempting_t); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "pomegranate/distributions.pyx":953
 * 		summaries = numpy.array( self.summaries )
 * 
 * 		statistic = _log( numpy.average( summaries[:,0],             # <<<<<<<<<<<<<<
 * 											 weights=summaries[:,3] ) ) - \
 * 					numpy.average( summaries[:,1],
 */
  __pyx_slice__7 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__7);
  __Pyx_GIVEREF(__pyx_slice__7);
  __pyx_tuple__8 = PyTuple_Pack(2, __pyx_slice__7, __pyx_int_0); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "pomegranate/distributions.pyx":954
 * 
 * 		statistic = _log( numpy.average( summaries[:,0],
 * 											 weights=summaries[:,3] ) ) - \             # <<<<<<<<<<<<<<
 * 					numpy.average( summaries[:,1],
 * 								   weights=summaries[:,3] )
 */
  __pyx_slice__9 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__9);
  __Pyx_GIVEREF(__pyx_slice__9);
  __pyx_tuple__10 = PyTuple_Pack(2, __pyx_slice__9, __pyx_int_3); if (unlikely(!__pyx_tuple__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "pomegranate/distributions.pyx":955
 * 		statistic = _log( numpy.average( summaries[:,0],
 * 											 weights=summaries[:,3] ) ) - \
 * 					numpy.average( summaries[:,1],             # <<<<<<<<<<<<<<
 * 								   weights=summaries[:,3] )
 * 
 */
  __pyx_slice__11 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__11);
  __Pyx_GIVEREF(__pyx_slice__11);
  __pyx_tuple__12 = PyTuple_Pack(2, __pyx_slice__11, __pyx_int_1); if (unlikely(!__pyx_tuple__12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "pomegranate/distributions.pyx":956
 * 											 weights=summaries[:,3] ) ) - \
 * 					numpy.average( summaries[:,1],
 * 								   weights=summaries[:,3] )             # <<<<<<<<<<<<<<
 * 
 * 		# Start our Newton-Raphson at what Wikipedia claims a 1969 paper claims
 */
  __pyx_slice__13 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__13);
  __Pyx_GIVEREF(__pyx_slice__13);
  __pyx_tuple__14 = PyTuple_Pack(2, __pyx_slice__13, __pyx_int_3); if (unlikely(!__pyx_tuple__14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "pomegranate/distributions.pyx":1003
 * 		# Now our iterative estimation of the shape parameter has converged.
 * 		# Calculate the rate parameter
 * 		rate = 1.0 / (1.0 / (shape * summaries[:,3].sum()) * \             # <<<<<<<<<<<<<<
 * 			numpy.sum( summaries[:,2] ) )
 * 
 */
  __pyx_slice__15 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__15);
  __Pyx_GIVEREF(__pyx_slice__15);
  __pyx_tuple__16 = PyTuple_Pack(2, __pyx_slice__15, __pyx_int_3); if (unlikely(!__pyx_tuple__16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "pomegranate/distributions.pyx":1004
 * 		# Calculate the rate parameter
 * 		rate = 1.0 / (1.0 / (shape * summaries[:,3].sum()) * \
 * 			numpy.sum( summaries[:,2] ) )             # <<<<<<<<<<<<<<
 * 
 * 		# Get the previous parameters
 */
  __pyx_slice__17 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__17);
  __Pyx_GIVEREF(__pyx_slice__17);
  __pyx_tuple__18 = PyTuple_Pack(2, __pyx_slice__17, __pyx_int_2); if (unlikely(!__pyx_tuple__18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "pomegranate/distributions.pyx":1569
 * 		# Weight the responsibilities by the given weights
 * 		for i in xrange( k ):
 * 			r[:,i] = r[:,i]*weights             # <<<<<<<<<<<<<<
 * 
 * 		# Update the emissions of each distribution
 */
  __pyx_slice__19 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__19);
  __Pyx_GIVEREF(__pyx_slice__19);
  __pyx_slice__20 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__20);
  __Pyx_GIVEREF(__pyx_slice__20);

  /* "pomegranate/distributions.pyx":1573
 * 		# Update the emissions of each distribution
 * 		for i, distribution in enumerate( distributions ):
 * 			distribution.from_sample( items, weights=r[:,i] )             # <<<<<<<<<<<<<<
 * 
 * 		# Update the weight of each distribution
 */
  __pyx_slice__21 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__21);
  __Pyx_GIVEREF(__pyx_slice__21);

  /* "pomegranate/distributions.pyx":1612
 * 		# Weight the responsibilities by the given weights
 * 		for i in xrange( k ):
 * 			r[:,i] = r[:,i]*weights             # <<<<<<<<<<<<<<
 * 
 * 		# Save summary statistics on the emission distributions
 */
  __pyx_slice__22 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__22);
  __Pyx_GIVEREF(__pyx_slice__22);
  __pyx_slice__23 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__23);
  __Pyx_GIVEREF(__pyx_slice__23);

  /* "pomegranate/distributions.pyx":1616
 * 		# Save summary statistics on the emission distributions
 * 		for i, distribution in enumerate( distributions ):
 * 			distribution.summarize( items, weights=r[:,i]*weights )             # <<<<<<<<<<<<<<
 * 
 * 		# Save summary statistics for weight updates
 */
  __pyx_slice__24 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__24);
  __Pyx_GIVEREF(__pyx_slice__24);

  /* "pomegranate/distributions.pyx":1647
 * 								                 self.parameters[1] ],
 * 								'frozen' : self.frozen
 * 						   }, separators=(',', ' : ' ), indent=4 )             # <<<<<<<<<<<<<<
 * 
 * cdef class MultivariateDistribution( Distribution ):
 */
  __pyx_tuple__25 = PyTuple_Pack(2, __pyx_kp_s__2, __pyx_kp_s__3); if (unlikely(!__pyx_tuple__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "pomegranate/distributions.pyx":1755
 * 		items, weights = weight_set( items, weights )
 * 		for i, d in enumerate( self.parameters[0] ):
 * 			d.summarize( items[:,i], weights=weights )             # <<<<<<<<<<<<<<
 * 
 * 	cdef void _summarize( self, double* items, double* weights, SIZE_t n ) nogil:
 */
  __pyx_slice__26 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__26);
  __Pyx_GIVEREF(__pyx_slice__26);

  /* "pomegranate/distributions.pyx":1787
 * 								                 self.parameters[1] ],
 * 								'frozen' : self.frozen
 * 						   }, separators=(',', ' : ' ), indent=4 )             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__27 = PyTuple_Pack(2, __pyx_kp_s__2, __pyx_kp_s__3); if (unlikely(!__pyx_tuple__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);

  /* "pomegranate/distributions.pyx":2003
 * 
 * 			for i, row in enumerate( table ):
 * 				keys.append( ( tuple(row[:-1]), i ) )             # <<<<<<<<<<<<<<
 * 				values[i] = _log( row[-1] )
 * 
 */
  __pyx_slice__28 = PySlice_New(Py_None, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_slice__28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__28);
  __Pyx_GIVEREF(__pyx_slice__28);

  /* "pomegranate/distributions.pyx":2006
 * 				values[i] = _log( row[-1] )
 * 
 * 			keys = OrderedDict( keys[::-1] )             # <<<<<<<<<<<<<<
 * 			self.parameters = [ values, parents, keys ]
 * 
 */
  __pyx_slice__29 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__29);
  __Pyx_GIVEREF(__pyx_slice__29);

  /* "pomegranate/distributions.pyx":2092
 * 		# Normalize the values
 * 		total = sum( row[-1] for row in table )
 * 		table = [ row[:-1] + (row[-1] / total,) for row in table ]             # <<<<<<<<<<<<<<
 * 
 * 		return JointProbabilityTable( table, parents )
 */
  __pyx_slice__32 = PySlice_New(Py_None, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_slice__32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__32);
  __Pyx_GIVEREF(__pyx_slice__32);

  /* "pomegranate/distributions.pyx":2108
 * 
 * 		# Get the index we're marginalizing over
 * 		i = -1 if neighbor_values == None else neighbor_values.index( None )             # <<<<<<<<<<<<<<
 * 		return self.joint( neighbor_values ).marginal( i )
 * 
 */
  __pyx_tuple__33 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);

  /* "pomegranate/distributions.pyx":2137
 * 
 * 			counts[item] = counts.get(item, 0) + weight
 * 			marginal_counts[item[:-1]] = marginal_counts.get(item[:-1], 0) + weight             # <<<<<<<<<<<<<<
 * 
 * 		values = numpy.zeros_like(self.parameters[0])
 */
  __pyx_slice__34 = PySlice_New(Py_None, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_slice__34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__34);
  __Pyx_GIVEREF(__pyx_slice__34);
  __pyx_slice__35 = PySlice_New(Py_None, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_slice__35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__35);
  __Pyx_GIVEREF(__pyx_slice__35);

  /* "pomegranate/distributions.pyx":2144
 * 		for key in self.parameters[2].keys():
 * 			count = counts.get( key, 0.0 )
 * 			marginal_count = marginal_counts.get( key[:-1], 0.0 )             # <<<<<<<<<<<<<<
 * 
 * 			probability = count / marginal_count if marginal_count > 0 else 1. / len(self)
 */
  __pyx_slice__36 = PySlice_New(Py_None, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_slice__36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__36);
  __Pyx_GIVEREF(__pyx_slice__36);

  /* "pomegranate/distributions.pyx":2177
 * 
 * 			for i, row in enumerate( table ):
 * 				keys.append( ( tuple(row[:-1]), i ) )             # <<<<<<<<<<<<<<
 * 				values[i] = _log( row[-1] )
 * 
 */
  __pyx_slice__37 = PySlice_New(Py_None, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_slice__37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__37);
  __Pyx_GIVEREF(__pyx_slice__37);

  /* "pomegranate/distributions.pyx":2180
 * 				values[i] = _log( row[-1] )
 * 
 * 			keys = OrderedDict( keys[::-1] )             # <<<<<<<<<<<<<<
 * 			self.parameters = [ values, neighbors, keys ]
 * 
 */
  __pyx_slice__38 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__38);
  __Pyx_GIVEREF(__pyx_slice__38);

  /* "pomegranate/distributions.pyx":2241
 * 			neighbor_values = [ neighbor_values.get( d, None ) for d in neighbors ]
 * 		if isinstance( neighbor_values, list ):
 * 			wrt = neighbor_values.index( None )             # <<<<<<<<<<<<<<
 * 
 * 		# Determine the keys for the respective parent distribution
 */
  __pyx_tuple__39 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 */
  __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__40)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
 * 
 *             info.buf = PyArray_DATA(self)
 */
  __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__41)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 */
  __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__42)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
 * 
 *         if ((child.byteorder == c'>' and little_endian) or
 */
  __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__43)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803
 *         if ((child.byteorder == c'>' and little_endian) or
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *             # One could encode it in the format string and have Cython
 *             # complain instead, BUT: < and > in format strings also imply
 */
  __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__44)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__44);
  __Pyx_GIVEREF(__pyx_tuple__44);

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823
 *             t = child.type_num
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 */
  __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__45)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);

  /* "pomegranate/distributions.pyx":40
 * DEF LOG_2_PI = 1.83787706641
 * 
 * def log(value):             # <<<<<<<<<<<<<<
 * 	"""
 * 	Return the natural log of the given value, or - infinity if the value is 0.
 */
  __pyx_tuple__46 = PyTuple_Pack(2, __pyx_n_s_value, __pyx_n_s_to_return); if (unlikely(!__pyx_tuple__46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__46);
  __Pyx_GIVEREF(__pyx_tuple__46);
  __pyx_codeobj__47 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__46, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_jmschr_Desktop_pomegranate, __pyx_n_s_log, 40, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "pomegranate/distributions.pyx":53
 * 	return _log( value )
 * 
 * def weight_set( items, weights ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	Set the weights to a numpy array of whatever is passed in, or an array of
 */
  __pyx_tuple__48 = PyTuple_Pack(2, __pyx_n_s_items, __pyx_n_s_weights); if (unlikely(!__pyx_tuple__48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__48);
  __Pyx_GIVEREF(__pyx_tuple__48);
  __pyx_codeobj__49 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__48, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_jmschr_Desktop_pomegranate, __pyx_n_s_weight_set, 53, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  __pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type;
  __pyx_umethod_PyDict_Type_keys.type = (PyObject*)&PyDict_Type;
  __pyx_umethod_PyDict_Type_values.type = (PyObject*)&PyDict_Type;
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_float_0_ = PyFloat_FromDouble(0.); if (unlikely(!__pyx_float_0_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_float_1_ = PyFloat_FromDouble(1.); if (unlikely(!__pyx_float_1_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_float_0_0 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_float_0_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_float_1_0 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_float_1_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_float_2_0 = PyFloat_FromDouble(2.0); if (unlikely(!__pyx_float_2_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_float_inf = PyFloat_FromDouble(Py_HUGE_VAL); if (unlikely(!__pyx_float_inf)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_float_0_01 = PyFloat_FromDouble(0.01); if (unlikely(!__pyx_float_0_01)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_float_1Eneg_9 = PyFloat_FromDouble(1E-9); if (unlikely(!__pyx_float_1Eneg_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_float_2_50662827463 = PyFloat_FromDouble(2.50662827463); if (unlikely(!__pyx_float_2_50662827463)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_float_neg_inf = PyFloat_FromDouble((-Py_HUGE_VAL)); if (unlikely(!__pyx_float_neg_inf)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_12 = PyInt_FromLong(12); if (unlikely(!__pyx_int_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_24 = PyInt_FromLong(24); if (unlikely(!__pyx_int_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_1000 = PyInt_FromLong(1000); if (unlikely(!__pyx_int_1000)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initdistributions(void); /*proto*/
PyMODINIT_FUNC initdistributions(void)
#else
PyMODINIT_FUNC PyInit_distributions(void); /*proto*/
PyMODINIT_FUNC PyInit_distributions(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_distributions(void)", 0);
  if (__Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("distributions", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  if (__pyx_module_is_main_pomegranate__distributions) {
    if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!PyDict_GetItemString(modules, "pomegranate.distributions")) {
      if (unlikely(PyDict_SetItemString(modules, "pomegranate.distributions", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_11pomegranate_13distributions_Distribution = &__pyx_vtable_11pomegranate_13distributions_Distribution;
  __pyx_vtable_11pomegranate_13distributions_Distribution._log_probability = (double (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double))__pyx_f_11pomegranate_13distributions_12Distribution__log_probability;
  __pyx_vtable_11pomegranate_13distributions_Distribution._mv_log_probability = (double (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double *))__pyx_f_11pomegranate_13distributions_12Distribution__mv_log_probability;
  __pyx_vtable_11pomegranate_13distributions_Distribution._summarize = (void (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double *, double *, __pyx_t_11pomegranate_13distributions_SIZE_t))__pyx_f_11pomegranate_13distributions_12Distribution__summarize;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_Distribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_Distribution.tp_print = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_11pomegranate_13distributions_Distribution, "__str__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_11pomegranate_13distributions_12Distribution_2__str__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_11pomegranate_13distributions_12Distribution_2__str__.doc = __pyx_doc_11pomegranate_13distributions_12Distribution_2__str__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_11pomegranate_13distributions_12Distribution_2__str__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_11pomegranate_13distributions_Distribution, "__repr__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_11pomegranate_13distributions_12Distribution_4__repr__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_11pomegranate_13distributions_12Distribution_4__repr__.doc = __pyx_doc_11pomegranate_13distributions_12Distribution_4__repr__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_11pomegranate_13distributions_12Distribution_4__repr__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_Distribution.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_Distribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "Distribution", (PyObject *)&__pyx_type_11pomegranate_13distributions_Distribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_Distribution = &__pyx_type_11pomegranate_13distributions_Distribution;
  __pyx_vtabptr_11pomegranate_13distributions_UniformDistribution = &__pyx_vtable_11pomegranate_13distributions_UniformDistribution;
  __pyx_vtable_11pomegranate_13distributions_UniformDistribution.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_Distribution;
  __pyx_vtable_11pomegranate_13distributions_UniformDistribution.__pyx_base._log_probability = (double (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double))__pyx_f_11pomegranate_13distributions_19UniformDistribution__log_probability;
  __pyx_vtable_11pomegranate_13distributions_UniformDistribution.__pyx_base._summarize = (void (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double *, double *, __pyx_t_11pomegranate_13distributions_SIZE_t))__pyx_f_11pomegranate_13distributions_19UniformDistribution__summarize;
  __pyx_type_11pomegranate_13distributions_UniformDistribution.tp_base = __pyx_ptype_11pomegranate_13distributions_Distribution;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_UniformDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_UniformDistribution.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_UniformDistribution.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_UniformDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "UniformDistribution", (PyObject *)&__pyx_type_11pomegranate_13distributions_UniformDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_UniformDistribution = &__pyx_type_11pomegranate_13distributions_UniformDistribution;
  __pyx_vtabptr_11pomegranate_13distributions_NormalDistribution = &__pyx_vtable_11pomegranate_13distributions_NormalDistribution;
  __pyx_vtable_11pomegranate_13distributions_NormalDistribution.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_Distribution;
  __pyx_vtable_11pomegranate_13distributions_NormalDistribution.__pyx_base._log_probability = (double (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double))__pyx_f_11pomegranate_13distributions_18NormalDistribution__log_probability;
  __pyx_vtable_11pomegranate_13distributions_NormalDistribution.__pyx_base._summarize = (void (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double *, double *, __pyx_t_11pomegranate_13distributions_SIZE_t))__pyx_f_11pomegranate_13distributions_18NormalDistribution__summarize;
  __pyx_type_11pomegranate_13distributions_NormalDistribution.tp_base = __pyx_ptype_11pomegranate_13distributions_Distribution;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_NormalDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_NormalDistribution.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_NormalDistribution.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_NormalDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "NormalDistribution", (PyObject *)&__pyx_type_11pomegranate_13distributions_NormalDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_NormalDistribution = &__pyx_type_11pomegranate_13distributions_NormalDistribution;
  __pyx_vtabptr_11pomegranate_13distributions_LogNormalDistribution = &__pyx_vtable_11pomegranate_13distributions_LogNormalDistribution;
  __pyx_vtable_11pomegranate_13distributions_LogNormalDistribution.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_Distribution;
  __pyx_vtable_11pomegranate_13distributions_LogNormalDistribution.__pyx_base._log_probability = (double (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double))__pyx_f_11pomegranate_13distributions_21LogNormalDistribution__log_probability;
  __pyx_vtable_11pomegranate_13distributions_LogNormalDistribution.__pyx_base._summarize = (void (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double *, double *, __pyx_t_11pomegranate_13distributions_SIZE_t))__pyx_f_11pomegranate_13distributions_21LogNormalDistribution__summarize;
  __pyx_type_11pomegranate_13distributions_LogNormalDistribution.tp_base = __pyx_ptype_11pomegranate_13distributions_Distribution;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_LogNormalDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_LogNormalDistribution.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_LogNormalDistribution.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_LogNormalDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "LogNormalDistribution", (PyObject *)&__pyx_type_11pomegranate_13distributions_LogNormalDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_LogNormalDistribution = &__pyx_type_11pomegranate_13distributions_LogNormalDistribution;
  __pyx_vtabptr_11pomegranate_13distributions_ExponentialDistribution = &__pyx_vtable_11pomegranate_13distributions_ExponentialDistribution;
  __pyx_vtable_11pomegranate_13distributions_ExponentialDistribution.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_Distribution;
  __pyx_vtable_11pomegranate_13distributions_ExponentialDistribution.__pyx_base._log_probability = (double (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double))__pyx_f_11pomegranate_13distributions_23ExponentialDistribution__log_probability;
  __pyx_vtable_11pomegranate_13distributions_ExponentialDistribution.__pyx_base._summarize = (void (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double *, double *, __pyx_t_11pomegranate_13distributions_SIZE_t))__pyx_f_11pomegranate_13distributions_23ExponentialDistribution__summarize;
  __pyx_type_11pomegranate_13distributions_ExponentialDistribution.tp_base = __pyx_ptype_11pomegranate_13distributions_Distribution;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_ExponentialDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_ExponentialDistribution.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_ExponentialDistribution.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_ExponentialDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "ExponentialDistribution", (PyObject *)&__pyx_type_11pomegranate_13distributions_ExponentialDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_ExponentialDistribution = &__pyx_type_11pomegranate_13distributions_ExponentialDistribution;
  __pyx_vtabptr_11pomegranate_13distributions_BetaDistribution = &__pyx_vtable_11pomegranate_13distributions_BetaDistribution;
  __pyx_vtable_11pomegranate_13distributions_BetaDistribution.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_Distribution;
  __pyx_vtable_11pomegranate_13distributions_BetaDistribution.__pyx_base._log_probability = (double (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double))__pyx_f_11pomegranate_13distributions_16BetaDistribution__log_probability;
  __pyx_vtable_11pomegranate_13distributions_BetaDistribution.__pyx_base._summarize = (void (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double *, double *, __pyx_t_11pomegranate_13distributions_SIZE_t))__pyx_f_11pomegranate_13distributions_16BetaDistribution__summarize;
  __pyx_type_11pomegranate_13distributions_BetaDistribution.tp_base = __pyx_ptype_11pomegranate_13distributions_Distribution;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_BetaDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_BetaDistribution.tp_print = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_11pomegranate_13distributions_BetaDistribution, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_11pomegranate_13distributions_16BetaDistribution___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_11pomegranate_13distributions_16BetaDistribution___init__.doc = __pyx_doc_11pomegranate_13distributions_16BetaDistribution___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_11pomegranate_13distributions_16BetaDistribution___init__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_BetaDistribution.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_BetaDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "BetaDistribution", (PyObject *)&__pyx_type_11pomegranate_13distributions_BetaDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_BetaDistribution = &__pyx_type_11pomegranate_13distributions_BetaDistribution;
  __pyx_vtabptr_11pomegranate_13distributions_GammaDistribution = &__pyx_vtable_11pomegranate_13distributions_GammaDistribution;
  __pyx_vtable_11pomegranate_13distributions_GammaDistribution.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_Distribution;
  __pyx_vtable_11pomegranate_13distributions_GammaDistribution.__pyx_base._log_probability = (double (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double))__pyx_f_11pomegranate_13distributions_17GammaDistribution__log_probability;
  __pyx_type_11pomegranate_13distributions_GammaDistribution.tp_base = __pyx_ptype_11pomegranate_13distributions_Distribution;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_GammaDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_GammaDistribution.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_GammaDistribution.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_GammaDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "GammaDistribution", (PyObject *)&__pyx_type_11pomegranate_13distributions_GammaDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_GammaDistribution = &__pyx_type_11pomegranate_13distributions_GammaDistribution;
  __pyx_vtabptr_11pomegranate_13distributions_DiscreteDistribution = &__pyx_vtable_11pomegranate_13distributions_DiscreteDistribution;
  __pyx_vtable_11pomegranate_13distributions_DiscreteDistribution.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_Distribution;
  __pyx_vtable_11pomegranate_13distributions_DiscreteDistribution.__pyx_base._log_probability = (double (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double))__pyx_f_11pomegranate_13distributions_20DiscreteDistribution__log_probability;
  __pyx_vtable_11pomegranate_13distributions_DiscreteDistribution.__pyx_base._summarize = (void (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double *, double *, __pyx_t_11pomegranate_13distributions_SIZE_t))__pyx_f_11pomegranate_13distributions_20DiscreteDistribution__summarize;
  __pyx_vtable_11pomegranate_13distributions_DiscreteDistribution.__pyx___log_probability = (double (*)(struct __pyx_obj_11pomegranate_13distributions_DiscreteDistribution *, PyObject *))__pyx_f_11pomegranate_13distributions_20DiscreteDistribution___log_probability;
  __pyx_type_11pomegranate_13distributions_DiscreteDistribution.tp_base = __pyx_ptype_11pomegranate_13distributions_Distribution;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_DiscreteDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_DiscreteDistribution.tp_print = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_11pomegranate_13distributions_DiscreteDistribution, "__len__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_11pomegranate_13distributions_20DiscreteDistribution_4__len__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_11pomegranate_13distributions_20DiscreteDistribution_4__len__.doc = __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_4__len__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_11pomegranate_13distributions_20DiscreteDistribution_4__len__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_11pomegranate_13distributions_DiscreteDistribution, "__mul__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_11pomegranate_13distributions_20DiscreteDistribution_6__mul__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_11pomegranate_13distributions_20DiscreteDistribution_6__mul__.doc = __pyx_doc_11pomegranate_13distributions_20DiscreteDistribution_6__mul__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_11pomegranate_13distributions_20DiscreteDistribution_6__mul__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_DiscreteDistribution.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_DiscreteDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "DiscreteDistribution", (PyObject *)&__pyx_type_11pomegranate_13distributions_DiscreteDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_DiscreteDistribution = &__pyx_type_11pomegranate_13distributions_DiscreteDistribution;
  __pyx_vtabptr_11pomegranate_13distributions_LambdaDistribution = &__pyx_vtable_11pomegranate_13distributions_LambdaDistribution;
  __pyx_vtable_11pomegranate_13distributions_LambdaDistribution.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_Distribution;
  __pyx_type_11pomegranate_13distributions_LambdaDistribution.tp_base = __pyx_ptype_11pomegranate_13distributions_Distribution;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_LambdaDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_LambdaDistribution.tp_print = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_11pomegranate_13distributions_LambdaDistribution, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_11pomegranate_13distributions_18LambdaDistribution___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_11pomegranate_13distributions_18LambdaDistribution___init__.doc = __pyx_doc_11pomegranate_13distributions_18LambdaDistribution___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_11pomegranate_13distributions_18LambdaDistribution___init__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_LambdaDistribution.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_LambdaDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "LambdaDistribution", (PyObject *)&__pyx_type_11pomegranate_13distributions_LambdaDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_LambdaDistribution = &__pyx_type_11pomegranate_13distributions_LambdaDistribution;
  __pyx_vtabptr_11pomegranate_13distributions_KernelDensity = &__pyx_vtable_11pomegranate_13distributions_KernelDensity;
  __pyx_vtable_11pomegranate_13distributions_KernelDensity.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_Distribution;
  __pyx_type_11pomegranate_13distributions_KernelDensity.tp_base = __pyx_ptype_11pomegranate_13distributions_Distribution;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_KernelDensity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_KernelDensity.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_KernelDensity.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_KernelDensity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "KernelDensity", (PyObject *)&__pyx_type_11pomegranate_13distributions_KernelDensity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_KernelDensity = &__pyx_type_11pomegranate_13distributions_KernelDensity;
  __pyx_vtabptr_11pomegranate_13distributions_GaussianKernelDensity = &__pyx_vtable_11pomegranate_13distributions_GaussianKernelDensity;
  __pyx_vtable_11pomegranate_13distributions_GaussianKernelDensity.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_KernelDensity;
  __pyx_vtable_11pomegranate_13distributions_GaussianKernelDensity.__pyx_base.__pyx_base._log_probability = (double (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double))__pyx_f_11pomegranate_13distributions_21GaussianKernelDensity__log_probability;
  __pyx_type_11pomegranate_13distributions_GaussianKernelDensity.tp_base = __pyx_ptype_11pomegranate_13distributions_KernelDensity;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_GaussianKernelDensity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_GaussianKernelDensity.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_GaussianKernelDensity.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_GaussianKernelDensity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "GaussianKernelDensity", (PyObject *)&__pyx_type_11pomegranate_13distributions_GaussianKernelDensity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_GaussianKernelDensity = &__pyx_type_11pomegranate_13distributions_GaussianKernelDensity;
  __pyx_vtabptr_11pomegranate_13distributions_UniformKernelDensity = &__pyx_vtable_11pomegranate_13distributions_UniformKernelDensity;
  __pyx_vtable_11pomegranate_13distributions_UniformKernelDensity.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_KernelDensity;
  __pyx_vtable_11pomegranate_13distributions_UniformKernelDensity.__pyx_base.__pyx_base._log_probability = (double (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double))__pyx_f_11pomegranate_13distributions_20UniformKernelDensity__log_probability;
  __pyx_type_11pomegranate_13distributions_UniformKernelDensity.tp_base = __pyx_ptype_11pomegranate_13distributions_KernelDensity;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_UniformKernelDensity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_UniformKernelDensity.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_UniformKernelDensity.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_UniformKernelDensity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "UniformKernelDensity", (PyObject *)&__pyx_type_11pomegranate_13distributions_UniformKernelDensity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_UniformKernelDensity = &__pyx_type_11pomegranate_13distributions_UniformKernelDensity;
  __pyx_vtabptr_11pomegranate_13distributions_TriangleKernelDensity = &__pyx_vtable_11pomegranate_13distributions_TriangleKernelDensity;
  __pyx_vtable_11pomegranate_13distributions_TriangleKernelDensity.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_KernelDensity;
  __pyx_vtable_11pomegranate_13distributions_TriangleKernelDensity.__pyx_base.__pyx_base._log_probability = (double (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double))__pyx_f_11pomegranate_13distributions_21TriangleKernelDensity__log_probability;
  __pyx_type_11pomegranate_13distributions_TriangleKernelDensity.tp_base = __pyx_ptype_11pomegranate_13distributions_KernelDensity;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_TriangleKernelDensity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_TriangleKernelDensity.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_TriangleKernelDensity.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_TriangleKernelDensity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "TriangleKernelDensity", (PyObject *)&__pyx_type_11pomegranate_13distributions_TriangleKernelDensity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_TriangleKernelDensity = &__pyx_type_11pomegranate_13distributions_TriangleKernelDensity;
  __pyx_vtabptr_11pomegranate_13distributions_MixtureDistribution = &__pyx_vtable_11pomegranate_13distributions_MixtureDistribution;
  __pyx_vtable_11pomegranate_13distributions_MixtureDistribution.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_Distribution;
  __pyx_vtable_11pomegranate_13distributions_MixtureDistribution.__pyx_base._log_probability = (double (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double))__pyx_f_11pomegranate_13distributions_19MixtureDistribution__log_probability;
  __pyx_type_11pomegranate_13distributions_MixtureDistribution.tp_base = __pyx_ptype_11pomegranate_13distributions_Distribution;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_MixtureDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_MixtureDistribution.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_MixtureDistribution.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_MixtureDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "MixtureDistribution", (PyObject *)&__pyx_type_11pomegranate_13distributions_MixtureDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_MixtureDistribution = &__pyx_type_11pomegranate_13distributions_MixtureDistribution;
  __pyx_vtabptr_11pomegranate_13distributions_MultivariateDistribution = &__pyx_vtable_11pomegranate_13distributions_MultivariateDistribution;
  __pyx_vtable_11pomegranate_13distributions_MultivariateDistribution.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_Distribution;
  __pyx_type_11pomegranate_13distributions_MultivariateDistribution.tp_base = __pyx_ptype_11pomegranate_13distributions_Distribution;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_MultivariateDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_MultivariateDistribution.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_MultivariateDistribution.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_MultivariateDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "MultivariateDistribution", (PyObject *)&__pyx_type_11pomegranate_13distributions_MultivariateDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_MultivariateDistribution = &__pyx_type_11pomegranate_13distributions_MultivariateDistribution;
  __pyx_vtabptr_11pomegranate_13distributions_IndependentComponentsDistribution = &__pyx_vtable_11pomegranate_13distributions_IndependentComponentsDistribution;
  __pyx_vtable_11pomegranate_13distributions_IndependentComponentsDistribution.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_MultivariateDistribution;
  __pyx_vtable_11pomegranate_13distributions_IndependentComponentsDistribution.__pyx_base.__pyx_base._mv_log_probability = (double (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double *))__pyx_f_11pomegranate_13distributions_33IndependentComponentsDistribution__mv_log_probability;
  __pyx_vtable_11pomegranate_13distributions_IndependentComponentsDistribution.__pyx_base.__pyx_base._summarize = (void (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double *, double *, __pyx_t_11pomegranate_13distributions_SIZE_t))__pyx_f_11pomegranate_13distributions_33IndependentComponentsDistribution__summarize;
  __pyx_type_11pomegranate_13distributions_IndependentComponentsDistribution.tp_base = __pyx_ptype_11pomegranate_13distributions_MultivariateDistribution;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_IndependentComponentsDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_IndependentComponentsDistribution.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_IndependentComponentsDistribution.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_IndependentComponentsDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "IndependentComponentsDistribution", (PyObject *)&__pyx_type_11pomegranate_13distributions_IndependentComponentsDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_IndependentComponentsDistribution = &__pyx_type_11pomegranate_13distributions_IndependentComponentsDistribution;
  __pyx_vtabptr_11pomegranate_13distributions_MultivariateGaussianDistribution = &__pyx_vtable_11pomegranate_13distributions_MultivariateGaussianDistribution;
  __pyx_vtable_11pomegranate_13distributions_MultivariateGaussianDistribution.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_MultivariateDistribution;
  __pyx_vtable_11pomegranate_13distributions_MultivariateGaussianDistribution.__pyx_base.__pyx_base._mv_log_probability = (double (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double *))__pyx_f_11pomegranate_13distributions_32MultivariateGaussianDistribution__mv_log_probability;
  __pyx_vtable_11pomegranate_13distributions_MultivariateGaussianDistribution.__pyx_base.__pyx_base._summarize = (void (*)(struct __pyx_obj_11pomegranate_13distributions_Distribution *, double *, double *, __pyx_t_11pomegranate_13distributions_SIZE_t))__pyx_f_11pomegranate_13distributions_32MultivariateGaussianDistribution__summarize;
  __pyx_vtable_11pomegranate_13distributions_MultivariateGaussianDistribution._from_summaries = (void (*)(struct __pyx_obj_11pomegranate_13distributions_MultivariateGaussianDistribution *, double))__pyx_f_11pomegranate_13distributions_32MultivariateGaussianDistribution__from_summaries;
  __pyx_type_11pomegranate_13distributions_MultivariateGaussianDistribution.tp_base = __pyx_ptype_11pomegranate_13distributions_MultivariateDistribution;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_MultivariateGaussianDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_MultivariateGaussianDistribution.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_MultivariateGaussianDistribution.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_MultivariateGaussianDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "MultivariateGaussianDistribution", (PyObject *)&__pyx_type_11pomegranate_13distributions_MultivariateGaussianDistribution) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_MultivariateGaussianDistribution = &__pyx_type_11pomegranate_13distributions_MultivariateGaussianDistribution;
  __pyx_vtabptr_11pomegranate_13distributions_ConditionalProbabilityTable = &__pyx_vtable_11pomegranate_13distributions_ConditionalProbabilityTable;
  __pyx_vtable_11pomegranate_13distributions_ConditionalProbabilityTable.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_MultivariateDistribution;
  __pyx_type_11pomegranate_13distributions_ConditionalProbabilityTable.tp_base = __pyx_ptype_11pomegranate_13distributions_MultivariateDistribution;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_ConditionalProbabilityTable) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_ConditionalProbabilityTable.tp_print = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_11pomegranate_13distributions_ConditionalProbabilityTable, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_11pomegranate_13distributions_27ConditionalProbabilityTable___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_11pomegranate_13distributions_27ConditionalProbabilityTable___init__.doc = __pyx_doc_11pomegranate_13distributions_27ConditionalProbabilityTable___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_11pomegranate_13distributions_27ConditionalProbabilityTable___init__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_11pomegranate_13distributions_ConditionalProbabilityTable, "__str__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_11pomegranate_13distributions_27ConditionalProbabilityTable_2__str__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_11pomegranate_13distributions_27ConditionalProbabilityTable_2__str__.doc = __pyx_doc_11pomegranate_13distributions_27ConditionalProbabilityTable_2__str__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_11pomegranate_13distributions_27ConditionalProbabilityTable_2__str__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_11pomegranate_13distributions_ConditionalProbabilityTable, "__len__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_11pomegranate_13distributions_27ConditionalProbabilityTable_4__len__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_11pomegranate_13distributions_27ConditionalProbabilityTable_4__len__.doc = __pyx_doc_11pomegranate_13distributions_27ConditionalProbabilityTable_4__len__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_11pomegranate_13distributions_27ConditionalProbabilityTable_4__len__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_ConditionalProbabilityTable.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_ConditionalProbabilityTable) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "ConditionalProbabilityTable", (PyObject *)&__pyx_type_11pomegranate_13distributions_ConditionalProbabilityTable) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_ConditionalProbabilityTable = &__pyx_type_11pomegranate_13distributions_ConditionalProbabilityTable;
  __pyx_vtabptr_11pomegranate_13distributions_JointProbabilityTable = &__pyx_vtable_11pomegranate_13distributions_JointProbabilityTable;
  __pyx_vtable_11pomegranate_13distributions_JointProbabilityTable.__pyx_base = *__pyx_vtabptr_11pomegranate_13distributions_MultivariateDistribution;
  __pyx_type_11pomegranate_13distributions_JointProbabilityTable.tp_base = __pyx_ptype_11pomegranate_13distributions_MultivariateDistribution;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions_JointProbabilityTable) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions_JointProbabilityTable.tp_print = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_11pomegranate_13distributions_JointProbabilityTable, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_11pomegranate_13distributions_21JointProbabilityTable___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_11pomegranate_13distributions_21JointProbabilityTable___init__.doc = __pyx_doc_11pomegranate_13distributions_21JointProbabilityTable___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_11pomegranate_13distributions_21JointProbabilityTable___init__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_11pomegranate_13distributions_JointProbabilityTable, "__str__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_11pomegranate_13distributions_21JointProbabilityTable_2__str__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_11pomegranate_13distributions_21JointProbabilityTable_2__str__.doc = __pyx_doc_11pomegranate_13distributions_21JointProbabilityTable_2__str__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_11pomegranate_13distributions_21JointProbabilityTable_2__str__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_11pomegranate_13distributions_JointProbabilityTable, "__len__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_11pomegranate_13distributions_21JointProbabilityTable_4__len__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_11pomegranate_13distributions_21JointProbabilityTable_4__len__.doc = __pyx_doc_11pomegranate_13distributions_21JointProbabilityTable_4__len__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_11pomegranate_13distributions_21JointProbabilityTable_4__len__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_11pomegranate_13distributions_JointProbabilityTable.tp_dict, __pyx_vtabptr_11pomegranate_13distributions_JointProbabilityTable) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "JointProbabilityTable", (PyObject *)&__pyx_type_11pomegranate_13distributions_JointProbabilityTable) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_11pomegranate_13distributions_JointProbabilityTable = &__pyx_type_11pomegranate_13distributions_JointProbabilityTable;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions___pyx_scope_struct____str__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions___pyx_scope_struct____str__.tp_print = 0;
  __pyx_ptype_11pomegranate_13distributions___pyx_scope_struct____str__ = &__pyx_type_11pomegranate_13distributions___pyx_scope_struct____str__;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions___pyx_scope_struct_1_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions___pyx_scope_struct_1_genexpr.tp_print = 0;
  __pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_1_genexpr = &__pyx_type_11pomegranate_13distributions___pyx_scope_struct_1_genexpr;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions___pyx_scope_struct_2_keys) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions___pyx_scope_struct_2_keys.tp_print = 0;
  __pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_2_keys = &__pyx_type_11pomegranate_13distributions___pyx_scope_struct_2_keys;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions___pyx_scope_struct_3_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions___pyx_scope_struct_3_genexpr.tp_print = 0;
  __pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_3_genexpr = &__pyx_type_11pomegranate_13distributions___pyx_scope_struct_3_genexpr;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions___pyx_scope_struct_4_joint) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions___pyx_scope_struct_4_joint.tp_print = 0;
  __pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_4_joint = &__pyx_type_11pomegranate_13distributions___pyx_scope_struct_4_joint;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions___pyx_scope_struct_5_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions___pyx_scope_struct_5_genexpr.tp_print = 0;
  __pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_5_genexpr = &__pyx_type_11pomegranate_13distributions___pyx_scope_struct_5_genexpr;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions___pyx_scope_struct_6___str__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions___pyx_scope_struct_6___str__.tp_print = 0;
  __pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_6___str__ = &__pyx_type_11pomegranate_13distributions___pyx_scope_struct_6___str__;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions___pyx_scope_struct_7_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions___pyx_scope_struct_7_genexpr.tp_print = 0;
  __pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_7_genexpr = &__pyx_type_11pomegranate_13distributions___pyx_scope_struct_7_genexpr;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions___pyx_scope_struct_8_keys) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions___pyx_scope_struct_8_keys.tp_print = 0;
  __pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_8_keys = &__pyx_type_11pomegranate_13distributions___pyx_scope_struct_8_keys;
  if (PyType_Ready(&__pyx_type_11pomegranate_13distributions___pyx_scope_struct_9_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_11pomegranate_13distributions___pyx_scope_struct_9_genexpr.tp_print = 0;
  __pyx_ptype_11pomegranate_13distributions___pyx_scope_struct_9_genexpr = &__pyx_type_11pomegranate_13distributions___pyx_scope_struct_9_genexpr;
  /*--- Type import code ---*/
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", 
  #if CYTHON_COMPILING_IN_PYPY
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("pomegranate.utils"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_1, "_log", (void (**)(void))&__pyx_f_11pomegranate_5utils__log, "double (double)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_1, "pair_lse", (void (**)(void))&__pyx_f_11pomegranate_5utils_pair_lse, "double (double, double)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif

  /* "pomegranate/distributions.pyx":15
 * from libc.math cimport sqrt as csqrt
 * 
 * import itertools as it             # <<<<<<<<<<<<<<
 * import json
 * import numpy
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_itertools, 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_it, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":16
 * 
 * import itertools as it
 * import json             # <<<<<<<<<<<<<<
 * import numpy
 * import random
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_json, 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_json, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":17
 * import itertools as it
 * import json
 * import numpy             # <<<<<<<<<<<<<<
 * import random
 * import scipy.special
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":18
 * import json
 * import numpy
 * import random             # <<<<<<<<<<<<<<
 * import scipy.special
 * import sys
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_random, 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_random, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":19
 * import numpy
 * import random
 * import scipy.special             # <<<<<<<<<<<<<<
 * import sys
 * 
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_scipy_special, 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_scipy, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":20
 * import random
 * import scipy.special
 * import sys             # <<<<<<<<<<<<<<
 * 
 * from .utils cimport pair_lse
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pomegranate/distributions.pyx":25
 * from .utils cimport _log
 * 
 * from collections import OrderedDict             # <<<<<<<<<<<<<<
 * 
 * if sys.version_info[0] > 2:
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_OrderedDict);
  __Pyx_GIVEREF(__pyx_n_s_OrderedDict);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_OrderedDict);
  __pyx_t_3 = __Pyx_Import(__pyx_n_s_collections, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_OrderedDict, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":27
 * from collections import OrderedDict
 * 
 * if sys.version_info[0] > 2:             # <<<<<<<<<<<<<<
 * 	# Set up for Python 3
 * 	xrange = range
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_version_info); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_int_2, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "pomegranate/distributions.pyx":29
 * if sys.version_info[0] > 2:
 * 	# Set up for Python 3
 * 	xrange = range             # <<<<<<<<<<<<<<
 * 	izip = zip
 * else:
 */
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_xrange, __pyx_builtin_range) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "pomegranate/distributions.pyx":30
 * 	# Set up for Python 3
 * 	xrange = range
 * 	izip = zip             # <<<<<<<<<<<<<<
 * else:
 * 	izip = it.izip
 */
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_izip, __pyx_builtin_zip) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "pomegranate/distributions.pyx":27
 * from collections import OrderedDict
 * 
 * if sys.version_info[0] > 2:             # <<<<<<<<<<<<<<
 * 	# Set up for Python 3
 * 	xrange = range
 */
    goto __pyx_L2;
  }

  /* "pomegranate/distributions.pyx":32
 * 	izip = zip
 * else:
 * 	izip = it.izip             # <<<<<<<<<<<<<<
 * 
 * # Define some useful constants
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_it); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_izip); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_izip, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L2:;

  /* "pomegranate/distributions.pyx":40
 * DEF LOG_2_PI = 1.83787706641
 * 
 * def log(value):             # <<<<<<<<<<<<<<
 * 	"""
 * 	Return the natural log of the given value, or - infinity if the value is 0.
 */
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_11pomegranate_13distributions_1log, NULL, __pyx_n_s_pomegranate_distributions); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_log, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":53
 * 	return _log( value )
 * 
 * def weight_set( items, weights ):             # <<<<<<<<<<<<<<
 * 	"""
 * 	Set the weights to a numpy array of whatever is passed in, or an array of
 */
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_11pomegranate_13distributions_3weight_set, NULL, __pyx_n_s_pomegranate_distributions); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_weight_set, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pomegranate/distributions.pyx":215
 * 
 * 	@classmethod
 * 	def from_json( cls, s ):             # <<<<<<<<<<<<<<
 * 		"""Read in a JSON and produce an appropriate distribution."""
 * 
 */
  __pyx_t_3 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_11pomegranate_13distributions_Distribution, __pyx_n_s_from_json); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "pomegranate/distributions.pyx":214
 * 						   }, separators=(',', ' : ' ), indent=4 )
 * 
 * 	@classmethod             # <<<<<<<<<<<<<<
 * 	def from_json( cls, s ):
 * 		"""Read in a JSON and produce an appropriate distribution."""
 */
  __pyx_t_2 = __Pyx_Method_ClassMethod(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_11pomegranate_13distributions_Distribution->tp_dict, __pyx_n_s_from_json, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_11pomegranate_13distributions_Distribution);

  /* "pomegranate/distributions.pyx":1
 * #!python             # <<<<<<<<<<<<<<
 * #cython: boundscheck=False
 * #cython: cdivision=True
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976
 *      arr.base = baseptr
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr.base is NULL:
 *         return None
 */

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init pomegranate.distributions", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init pomegranate.distributions");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* --- Runtime support code --- */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON
    result = PyDict_GetItem(__pyx_d, name);
    if (likely(result)) {
        Py_INCREF(result);
    } else {
#else
    result = PyObject_GetItem(__pyx_d, name);
    if (!result) {
        PyErr_Clear();
#endif
        result = __Pyx_GetBuiltinName(name);
    }
    return result;
}

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = func->ob_type->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject* args = PyTuple_Pack(1, arg);
    return (likely(args)) ? __Pyx_PyObject_Call(func, args, NULL) : NULL;
}
#endif

#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    if (op1 == op2) {
        Py_RETURN_TRUE;
    }
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
        if (a == b) {
            Py_RETURN_TRUE;
        } else {
            Py_RETURN_FALSE;
        }
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a;
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    }
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    }
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    }
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    }
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    }
                #if PyLong_SHIFT < 30 && PyLong_SHIFT != 15
                default: return PyLong_Type.tp_richcompare(op1, op2, Py_EQ);
                #else
                default: Py_RETURN_FALSE;
                #endif
            }
        }
            if (a == b) {
                Py_RETURN_TRUE;
            } else {
                Py_RETURN_FALSE;
            }
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            if ((double)a == (double)b) {
                Py_RETURN_TRUE;
            } else {
                Py_RETURN_FALSE;
            }
    }
    return PyObject_RichCompare(op1, op2, Py_EQ);
}
#endif

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (PyErr_ExceptionMatches(PyExc_OverflowError))
                        PyErr_Clear();
                    else
                        return NULL;
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
#if CYTHON_COMPILING_IN_PYPY
    if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
        goto invalid_keyword;
    return 1;
#else
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
        #endif
            if (unlikely(!PyUnicode_Check(key)))
                goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    return 0;
#endif
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_Restore(type, value, tb);
#endif
}
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(type, value, tb);
#endif
}

#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
#if PY_VERSION_HEX >= 0x03030000
    if (cause) {
#else
    if (cause && cause != Py_None) {
#endif
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_VERSION_HEX < 0x03030000
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                #if PY_VERSION_HEX < 0x03030000
                PyObject *py_level = PyInt_FromLong(1);
                if (!py_level)
                    goto bad;
                module = PyObject_CallFunctionObjArgs(py_import,
                    name, global_dict, empty_dict, list, py_level, NULL);
                Py_DECREF(py_level);
                #else
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                #endif
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_VERSION_HEX < 0x03030000
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_VERSION_HEX < 0x03030000
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
                                               CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
        if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (PyErr_ExceptionMatches(PyExc_OverflowError))
                        PyErr_Clear();
                    else
                        return -1;
                }
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) {
#else
    if (is_list || PySequence_Check(o)) {
#endif
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

#if !CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
    return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
}
#endif

static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#endif
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_SubtractCObj(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op2))) {
        const long a = intval;
        long x;
        long b = PyInt_AS_LONG(op2);
            x = (long)((unsigned long)a - b);
            if (likely((x^a) >= 0 || (x^~b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
    if (likely(PyLong_CheckExact(op2))) {
        const long a = intval;
        long b, x;
        const PY_LONG_LONG lla = intval;
        PY_LONG_LONG llb, llx;
        const digit* digits = ((PyLongObject*)op2)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op2);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            b = likely(size) ? digits[0] : 0;
            if (size == -1) b = -b;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        b = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        b = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        b = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        b = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        b = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        b = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
            }
        }
                x = a - b;
            return PyLong_FromLong(x);
        long_long:
                llx = lla - llb;
            return PyLong_FromLongLong(llx);
    }
    #endif
    if (PyFloat_CheckExact(op2)) {
        const long a = intval;
        double b = PyFloat_AS_DOUBLE(op2);
            double result;
            PyFPE_START_PROTECT("subtract", return NULL)
            result = ((double)a) - (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
}
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyFloat_EqObjC(PyObject *op1, PyObject *op2, double floatval, CYTHON_UNUSED int inplace) {
    const double b = floatval;
    double a;
    if (op1 == op2) {
        Py_RETURN_TRUE;
    }
    if (likely(PyFloat_CheckExact(op1))) {
        a = PyFloat_AS_DOUBLE(op1);
    } else
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        a = (double) PyInt_AS_LONG(op1);
    } else
    #endif
    if (likely(PyLong_CheckExact(op1))) {
        #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        switch (size) {
            case  0: a = 0.0; break;
            case -1: a = -(double) digits[0]; break;
            case  1: a = (double) digits[0]; break;
            case -2:
            case 2:
                if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) {
                    a = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (a < (double) (1L<<53))) {
                        if (size == -2)
                            a = -a;
                        break;
                    }
                }
            case -3:
            case 3:
                if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) {
                    a = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (a < (double) (1L<<53))) {
                        if (size == -3)
                            a = -a;
                        break;
                    }
                }
            case -4:
            case 4:
                if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) {
                    a = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (a < (double) (1L<<53))) {
                        if (size == -4)
                            a = -a;
                        break;
                    }
                }
            default:
        #else
        {
        #endif
            return PyFloat_Type.tp_richcompare(op2, op1, Py_EQ);
        }
    } else {
        return PyObject_RichCompare(op1, op2, Py_EQ);
    }
        if (a == b) {
            Py_RETURN_TRUE;
        } else {
            Py_RETURN_FALSE;
        }
}
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyFloat_DivideCObj(PyObject *op1, PyObject *op2, double floatval, CYTHON_UNUSED int inplace) {
    const double a = floatval;
    double b, result;
    if (likely(PyFloat_CheckExact(op2))) {
        b = PyFloat_AS_DOUBLE(op2);
    } else
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op2))) {
        b = (double) PyInt_AS_LONG(op2);
    } else
    #endif
    if (likely(PyLong_CheckExact(op2))) {
        #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
        const digit* digits = ((PyLongObject*)op2)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op2);
        switch (size) {
            case  0: b = 0.0; break;
            case -1: b = -(double) digits[0]; break;
            case  1: b = (double) digits[0]; break;
            case -2:
            case 2:
                if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) {
                    b = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (b < (double) (1L<<53))) {
                        if (size == -2)
                            b = -b;
                        break;
                    }
                }
            case -3:
            case 3:
                if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) {
                    b = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (b < (double) (1L<<53))) {
                        if (size == -3)
                            b = -b;
                        break;
                    }
                }
            case -4:
            case 4:
                if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) {
                    b = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (b < (double) (1L<<53))) {
                        if (size == -4)
                            b = -b;
                        break;
                    }
                }
            default:
        #else
        {
        #endif
            b = PyLong_AsDouble(op2);
            if (unlikely(b == -1.0 && PyErr_Occurred())) return NULL;
        }
    } else {
        return (inplace ? __Pyx_PyNumber_InPlaceDivide(op1, op2) : __Pyx_PyNumber_Divide(op1, op2));
    }
        PyFPE_START_PROTECT("divide", return NULL)
        result = a / b;
        PyFPE_END_PROTECT(result)
        return PyFloat_FromDouble(result);
}
#endif

static double __Pyx__PyObject_AsDouble(PyObject* obj) {
    PyObject* float_value;
#if CYTHON_COMPILING_IN_PYPY
    float_value = PyNumber_Float(obj);  if (0) goto bad;
#else
    PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number;
    if (likely(nb) && likely(nb->nb_float)) {
        float_value = nb->nb_float(obj);
        if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) {
            PyErr_Format(PyExc_TypeError,
                "__float__ returned non-float (type %.200s)",
                Py_TYPE(float_value)->tp_name);
            Py_DECREF(float_value);
            goto bad;
        }
    } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
#if PY_MAJOR_VERSION >= 3
        float_value = PyFloat_FromString(obj);
#else
        float_value = PyFloat_FromString(obj, 0);
#endif
    } else {
        PyObject* args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        PyTuple_SET_ITEM(args, 0, obj);
        float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0);
        PyTuple_SET_ITEM(args, 0, 0);
        Py_DECREF(args);
    }
#endif
    if (likely(float_value)) {
        double value = PyFloat_AS_DOUBLE(float_value);
        Py_DECREF(float_value);
        return value;
    }
bad:
    return (double)-1;
}

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a - b);
            if (likely((x^a) >= 0 || (x^~b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
            }
        }
                x = a - b;
            return PyLong_FromLong(x);
        long_long:
                llx = lla - llb;
            return PyLong_FromLongLong(llx);
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("subtract", return NULL)
            result = ((double)a) - (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
}
#endif

static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        goto long_long;
                    }
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
}
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (likely(Py_TYPE(obj) == type)) return 1;
        #if PY_MAJOR_VERSION == 2
        else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(PyObject_TypeCheck(obj, type))) return 1;
    }
    __Pyx_RaiseArgumentTypeInvalid(name, obj, type);
    return 0;
}

static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    target->method = method;
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION >= 3
    if (likely(PyObject_TypeCheck(method, &PyMethodDescr_Type)))
    #endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_O | METH_NOARGS);
    }
#endif
    return 0;
}

static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    args = PyTuple_New(1);
    if (unlikely(!args)) goto bad;
    Py_INCREF(self);
    PyTuple_SET_ITEM(args, 0, self);
#else
    args = PyTuple_Pack(1, self);
    if (unlikely(!args)) goto bad;
#endif
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    Py_DECREF(args);
bad:
    return result;
}

static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) {
    if (PY_MAJOR_VERSION >= 3)
        return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_items, d);
    else
        return PyDict_Items(d);
}

static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d) {
    if (PY_MAJOR_VERSION >= 3)
        return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_keys, d);
    else
        return PyDict_Keys(d);
}

static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d) {
    if (PY_MAJOR_VERSION >= 3)
        return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_values, d);
    else
        return PyDict_Values(d);
}

static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
    PyObject* value;
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (unlikely(PyErr_Occurred()))
            return NULL;
        value = default_value;
    }
    Py_INCREF(value);
#else
    if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
        value = PyDict_GetItem(d, key);
        if (unlikely(!value)) {
            value = default_value;
        }
        Py_INCREF(value);
    } else {
        if (default_value == Py_None)
            default_value = NULL;
        value = PyObject_CallMethodObjArgs(
            d, __pyx_n_s_get, key, default_value, NULL);
    }
#endif
    return value;
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method, *result = NULL;
    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
    if (unlikely(!method)) goto bad;
#if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyMethod_Check(method))) {
        PyObject *self = PyMethod_GET_SELF(method);
        if (likely(self)) {
            PyObject *args;
            PyObject *function = PyMethod_GET_FUNCTION(method);
            args = PyTuple_New(2);
            if (unlikely(!args)) goto bad;
            Py_INCREF(self);
            PyTuple_SET_ITEM(args, 0, self);
            Py_INCREF(arg);
            PyTuple_SET_ITEM(args, 1, arg);
            Py_INCREF(function);
            Py_DECREF(method); method = NULL;
            result = __Pyx_PyObject_Call(function, args, NULL);
            Py_DECREF(args);
            Py_DECREF(function);
            return result;
        }
    }
#endif
    result = __Pyx_PyObject_CallOneArg(method, arg);
bad:
    Py_XDECREF(method);
    return result;
}

static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
    } else {
        PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
        if (unlikely(!retval))
            return -1;
        Py_DECREF(retval);
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (PyErr_ExceptionMatches(PyExc_OverflowError))
                    PyErr_Clear();
                else
                    goto bad;
            }
        }
        return ms->sq_slice(obj, cstart, cstop);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_subscript))
#endif
    {
        PyObject* result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_COMPILING_IN_CPYTHON
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
    PyObject *result;
    result = __Pyx_PyObject_GetAttrStr(nmspace, name);
    if (!result)
        result = __Pyx_GetModuleGlobalName(name);
    return result;
}

static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = start + (end - start) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        __pyx_d,      /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = py_line;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_COMPILING_IN_CPYTHON
#if PY_MAJOR_VERSION >= 3
    if (likely(PyUnicode_Check(n)))
#else
    if (likely(PyString_Check(n)))
#endif
        return __Pyx_PyObject_GetAttrStr(o, n);
#endif
    return PyObject_GetAttr(o, n);
}

static PyObject* __Pyx_Globals(void) {
    Py_ssize_t i;
    PyObject *names;
    PyObject *globals = __pyx_d;
    Py_INCREF(globals);
    names = PyObject_Dir(__pyx_m);
    if (!names)
        goto bad;
    for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject* name = PySequence_ITEM(names, i);
        if (!name)
            goto bad;
#else
        PyObject* name = PyList_GET_ITEM(names, i);
#endif
        if (!PyDict_Contains(globals, name)) {
            PyObject* value = __Pyx_GetAttr(__pyx_m, name);
            if (!value) {
#if CYTHON_COMPILING_IN_PYPY
                Py_DECREF(name);
#endif
                goto bad;
            }
            if (PyDict_SetItem(globals, name, value) < 0) {
#if CYTHON_COMPILING_IN_PYPY
                Py_DECREF(name);
#endif
                Py_DECREF(value);
                goto bad;
            }
        }
#if CYTHON_COMPILING_IN_PYPY
        Py_DECREF(name);
#endif
    }
    Py_DECREF(names);
    return globals;
bad:
    Py_XDECREF(names);
    Py_XDECREF(globals);
    return NULL;
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value) {
    const Py_intptr_t neg_one = (Py_intptr_t) -1, const_zero = (Py_intptr_t) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(Py_intptr_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(Py_intptr_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(Py_intptr_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(Py_intptr_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(Py_intptr_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(Py_intptr_t),
                                     little, !is_unsigned);
    }
}

#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) -1, const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) digits[0])
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) -(((((int)digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) -(((((((int)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) -(((((((((int)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

static CYTHON_INLINE Py_intptr_t __Pyx_PyInt_As_Py_intptr_t(PyObject *x) {
    const Py_intptr_t neg_one = (Py_intptr_t) -1, const_zero = (Py_intptr_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(Py_intptr_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(Py_intptr_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (Py_intptr_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (Py_intptr_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(Py_intptr_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(Py_intptr_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) >= 2 * PyLong_SHIFT) {
                            return (Py_intptr_t) (((((Py_intptr_t)digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(Py_intptr_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) >= 3 * PyLong_SHIFT) {
                            return (Py_intptr_t) (((((((Py_intptr_t)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(Py_intptr_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) >= 4 * PyLong_SHIFT) {
                            return (Py_intptr_t) (((((((((Py_intptr_t)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (Py_intptr_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(Py_intptr_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(Py_intptr_t, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(Py_intptr_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(Py_intptr_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (Py_intptr_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(Py_intptr_t, sdigit, -(sdigit) digits[0])
                case  1: __PYX_VERIFY_RETURN_INT(Py_intptr_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(Py_intptr_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) - 1 > 2 * PyLong_SHIFT) {
                            return (Py_intptr_t) -(((((Py_intptr_t)digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(Py_intptr_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) - 1 > 2 * PyLong_SHIFT) {
                            return (Py_intptr_t) (((((Py_intptr_t)digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(Py_intptr_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) - 1 > 3 * PyLong_SHIFT) {
                            return (Py_intptr_t) -(((((((Py_intptr_t)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(Py_intptr_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) - 1 > 3 * PyLong_SHIFT) {
                            return (Py_intptr_t) (((((((Py_intptr_t)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(Py_intptr_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) - 1 > 4 * PyLong_SHIFT) {
                            return (Py_intptr_t) -(((((((((Py_intptr_t)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(Py_intptr_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) - 1 > 4 * PyLong_SHIFT) {
                            return (Py_intptr_t) (((((((((Py_intptr_t)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(Py_intptr_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(Py_intptr_t, long, PyLong_AsLong(x))
            } else if (sizeof(Py_intptr_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(Py_intptr_t, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            Py_intptr_t val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (Py_intptr_t) -1;
        }
    } else {
        Py_intptr_t val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (Py_intptr_t) -1;
        val = __Pyx_PyInt_As_Py_intptr_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to Py_intptr_t");
    return (Py_intptr_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to Py_intptr_t");
    return (Py_intptr_t) -1;
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
    const int neg_one = (int) -1, const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
    const size_t neg_one = (size_t) -1, const_zero = (size_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(size_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (size_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (size_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
                            return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
                            return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
                            return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (size_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(size_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (size_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, -(sdigit) digits[0])
                case  1: __PYX_VERIFY_RETURN_INT(size_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                            return (size_t) -(((((size_t)digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                            return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                            return (size_t) -(((((((size_t)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                            return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
                            return (size_t) -(((((((((size_t)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
                            return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(size_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
            } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            size_t val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (size_t) -1;
        }
    } else {
        size_t val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (size_t) -1;
        val = __Pyx_PyInt_As_size_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to size_t");
    return (size_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to size_t");
    return (size_t) -1;
}

static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
#if CYTHON_COMPILING_IN_PYPY
    if (PyObject_TypeCheck(method, &PyWrapperDescr_Type)) {
        return PyClassMethod_New(method);
    }
#else
    static PyTypeObject *methoddescr_type = NULL;
    if (methoddescr_type == NULL) {
       PyObject *meth = PyObject_GetAttrString((PyObject*)&PyList_Type, "append");
       if (!meth) return NULL;
       methoddescr_type = Py_TYPE(meth);
       Py_DECREF(meth);
    }
    if (PyObject_TypeCheck(method, methoddescr_type)) {
        PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
        #if PY_VERSION_HEX < 0x03020000
        PyTypeObject *d_type = descr->d_type;
        #else
        PyTypeObject *d_type = descr->d_common.d_type;
        #endif
        return PyDescr_NewClassMethod(d_type, descr->d_method);
    }
#endif
    else if (PyMethod_Check(method)) {
        return PyClassMethod_New(PyMethod_GET_FUNCTION(method));
    }
    else if (PyCFunction_Check(method)) {
        return PyClassMethod_New(method);
    }
#ifdef __Pyx_CyFunction_USED
    else if (PyObject_TypeCheck(method, __pyx_CyFunctionType)) {
        return PyClassMethod_New(method);
    }
#endif
    PyErr_SetString(PyExc_TypeError,
                   "Class-level classmethod() can only be called on "
                   "a method_descriptor or instance method.");
    return NULL;
}

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return ::std::complex< float >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return x + y*(__pyx_t_float_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      __pyx_t_float_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

#if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        float denom = b.real * b.real + b.imag * b.imag;
        z.real = (a.real * b.real + a.imag * b.imag) / denom;
        z.imag = (a.imag * b.real - a.real * b.imag) / denom;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrtf(z.real*z.real + z.imag*z.imag);
          #else
            return hypotf(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
            __pyx_t_float_complex z;
            float r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    float denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        z = __Pyx_c_prodf(a, a);
                        return __Pyx_c_prodf(a, a);
                    case 3:
                        z = __Pyx_c_prodf(a, a);
                        return __Pyx_c_prodf(z, a);
                    case 4:
                        z = __Pyx_c_prodf(a, a);
                        return __Pyx_c_prodf(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                }
                r = a.real;
                theta = 0;
            } else {
                r = __Pyx_c_absf(a);
                theta = atan2f(a.imag, a.real);
            }
            lnr = logf(r);
            z_r = expf(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cosf(z_theta);
            z.imag = z_r * sinf(z_theta);
            return z;
        }
    #endif
#endif

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return ::std::complex< double >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return x + y*(__pyx_t_double_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      __pyx_t_double_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

#if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        double denom = b.real * b.real + b.imag * b.imag;
        z.real = (a.real * b.real + a.imag * b.imag) / denom;
        z.imag = (a.imag * b.real - a.real * b.imag) / denom;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrt(z.real*z.real + z.imag*z.imag);
          #else
            return hypot(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) {
            __pyx_t_double_complex z;
            double r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    double denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        z = __Pyx_c_prod(a, a);
                        return __Pyx_c_prod(a, a);
                    case 3:
                        z = __Pyx_c_prod(a, a);
                        return __Pyx_c_prod(z, a);
                    case 4:
                        z = __Pyx_c_prod(a, a);
                        return __Pyx_c_prod(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                }
                r = a.real;
                theta = 0;
            } else {
                r = __Pyx_c_abs(a);
                theta = atan2(a.imag, a.real);
            }
            lnr = log(r);
            z_r = exp(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cos(z_theta);
            z.imag = z_r * sin(z_theta);
            return z;
        }
    #endif
#endif

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) {
    const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum NPY_TYPES) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(enum NPY_TYPES) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) digits[0])
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) -(((((long)digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) -(((((((long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) -(((((((((long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
    PyObject* fake_module;
    PyTypeObject* cached_type = NULL;
    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
    if (!fake_module) return NULL;
    Py_INCREF(fake_module);
    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
    if (cached_type) {
        if (!PyType_Check((PyObject*)cached_type)) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s is not a type object",
                type->tp_name);
            goto bad;
        }
        if (cached_type->tp_basicsize != type->tp_basicsize) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s has the wrong size, try recompiling",
                type->tp_name);
            goto bad;
        }
    } else {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        if (PyType_Ready(type) < 0) goto bad;
        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
            goto bad;
        Py_INCREF(type);
        cached_type = type;
    }
done:
    Py_DECREF(fake_module);
    return cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = *type;
    tstate->exc_value = *value;
    tstate->exc_traceback = *tb;
#else
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
#endif
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}

#include <structmember.h>
#include <frameobject.h>
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
static PyObject *__Pyx_Coroutine_Close(PyObject *self);
static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
#define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
#if 1 || PY_VERSION_HEX < 0x030300B0
static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) {
    PyObject *et, *ev, *tb;
    PyObject *value = NULL;
    __Pyx_ErrFetch(&et, &ev, &tb);
    if (!et) {
        Py_XDECREF(tb);
        Py_XDECREF(ev);
        Py_INCREF(Py_None);
        *pvalue = Py_None;
        return 0;
    }
    if (likely(et == PyExc_StopIteration)) {
#if PY_VERSION_HEX >= 0x030300A0
        if (ev && Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
            value = ((PyStopIterationObject *)ev)->value;
            Py_INCREF(value);
            Py_DECREF(ev);
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = value;
            return 0;
        }
#endif
        if (!ev || !PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
            if (!ev) {
                Py_INCREF(Py_None);
                ev = Py_None;
            } else if (PyTuple_Check(ev)) {
                if (PyTuple_GET_SIZE(ev) >= 1) {
                    PyObject *value;
#if CYTHON_COMPILING_IN_CPYTHON
                    value = PySequence_ITEM(ev, 0);
#else
                    value = PyTuple_GET_ITEM(ev, 0);
                    Py_INCREF(value);
#endif
                    Py_DECREF(ev);
                    ev = value;
                } else {
                    Py_INCREF(Py_None);
                    Py_DECREF(ev);
                    ev = Py_None;
                }
            }
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = ev;
            return 0;
        }
    } else if (!PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    PyErr_NormalizeException(&et, &ev, &tb);
    if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    Py_XDECREF(tb);
    Py_DECREF(et);
#if PY_VERSION_HEX >= 0x030300A0
    value = ((PyStopIterationObject *)ev)->value;
    Py_INCREF(value);
    Py_DECREF(ev);
#else
    {
        PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
        Py_DECREF(ev);
        if (likely(args)) {
            value = PySequence_GetItem(args, 0);
            Py_DECREF(args);
        }
        if (unlikely(!value)) {
            __Pyx_ErrRestore(NULL, NULL, NULL);
            Py_INCREF(Py_None);
            value = Py_None;
        }
    }
#endif
    *pvalue = value;
    return 0;
}
#endif
static CYTHON_INLINE
void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) {
    PyObject *exc_type = self->exc_type;
    PyObject *exc_value = self->exc_value;
    PyObject *exc_traceback = self->exc_traceback;
    self->exc_type = NULL;
    self->exc_value = NULL;
    self->exc_traceback = NULL;
    Py_XDECREF(exc_type);
    Py_XDECREF(exc_value);
    Py_XDECREF(exc_traceback);
}
static CYTHON_INLINE
int __Pyx_Coroutine_CheckRunning(__pyx_CoroutineObject *gen) {
    if (unlikely(gen->is_running)) {
        PyErr_SetString(PyExc_ValueError,
                        "generator already executing");
        return 1;
    }
    return 0;
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value) {
    PyObject *retval;
    assert(!self->is_running);
    if (unlikely(self->resume_label == 0)) {
        if (unlikely(value && value != Py_None)) {
            PyErr_SetString(PyExc_TypeError,
                            "can't send non-None value to a "
                            "just-started generator");
            return NULL;
        }
    }
    if (unlikely(self->resume_label == -1)) {
        PyErr_SetNone(PyExc_StopIteration);
        return NULL;
    }
    if (value) {
#if CYTHON_COMPILING_IN_PYPY
#else
        if (self->exc_traceback) {
            PyThreadState *tstate = PyThreadState_GET();
            PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            Py_XINCREF(tstate->frame);
            assert(f->f_back == NULL);
            f->f_back = tstate->frame;
        }
#endif
        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
                            &self->exc_traceback);
    } else {
        __Pyx_Coroutine_ExceptionClear(self);
    }
    self->is_running = 1;
    retval = self->body((PyObject *) self, value);
    self->is_running = 0;
    if (retval) {
        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
                            &self->exc_traceback);
#if CYTHON_COMPILING_IN_PYPY
#else
        if (self->exc_traceback) {
            PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            Py_CLEAR(f->f_back);
        }
#endif
    } else {
        __Pyx_Coroutine_ExceptionClear(self);
    }
    return retval;
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_MethodReturn(PyObject *retval) {
    if (unlikely(!retval && !PyErr_Occurred())) {
        PyErr_SetNone(PyExc_StopIteration);
    }
    return retval;
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
    PyObject *ret;
    PyObject *val = NULL;
    __Pyx_Coroutine_Undelegate(gen);
    __Pyx_PyGen_FetchStopIterationValue(&val);
    ret = __Pyx_Coroutine_SendEx(gen, val);
    Py_XDECREF(val);
    return ret;
}
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
    PyObject *retval;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(__Pyx_Coroutine_CheckRunning(gen)))
        return NULL;
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        {
            if (value == Py_None)
                ret = PyIter_Next(yf);  // FIXME!
            else
                ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
        }
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        retval = __Pyx_Coroutine_FinishDelegation(gen);
    } else {
        retval = __Pyx_Coroutine_SendEx(gen, value);
    }
    return __Pyx_Coroutine_MethodReturn(retval);
}
static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
    PyObject *retval = NULL;
    int err = 0;
    #ifdef __Pyx_Generator_USED
    if (__Pyx_Generator_CheckExact(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_Coroutine_USED
    if (__Pyx_Coroutine_CheckExact(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    #endif
    {
        PyObject *meth;
        gen->is_running = 1;
        meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
        if (unlikely(!meth)) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                PyErr_WriteUnraisable(yf);
            }
            PyErr_Clear();
        } else {
            retval = PyObject_CallFunction(meth, NULL);
            Py_DECREF(meth);
            if (!retval)
                err = -1;
        }
        gen->is_running = 0;
    }
    Py_XDECREF(retval);
    return err;
}
static PyObject *__Pyx_Generator_Next(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(__Pyx_Coroutine_CheckRunning(gen)))
        return NULL;
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        ret = Py_TYPE(yf)->tp_iternext(yf);
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        return __Pyx_Coroutine_FinishDelegation(gen);
    }
    return __Pyx_Coroutine_SendEx(gen, Py_None);
}
static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *retval, *raised_exception;
    PyObject *yf = gen->yieldfrom;
    int err = 0;
    if (unlikely(__Pyx_Coroutine_CheckRunning(gen)))
        return NULL;
    if (yf) {
        Py_INCREF(yf);
        err = __Pyx_Coroutine_CloseIter(gen, yf);
        __Pyx_Coroutine_Undelegate(gen);
        Py_DECREF(yf);
    }
    if (err == 0)
        PyErr_SetNone(PyExc_GeneratorExit);
    retval = __Pyx_Coroutine_SendEx(gen, NULL);
    if (retval) {
        Py_DECREF(retval);
        PyErr_SetString(PyExc_RuntimeError,
                        "generator ignored GeneratorExit");
        return NULL;
    }
    raised_exception = PyErr_Occurred();
    if (!raised_exception
        || raised_exception == PyExc_StopIteration
        || raised_exception == PyExc_GeneratorExit
        || PyErr_GivenExceptionMatches(raised_exception, PyExc_GeneratorExit)
        || PyErr_GivenExceptionMatches(raised_exception, PyExc_StopIteration))
    {
        if (raised_exception) PyErr_Clear();
        Py_INCREF(Py_None);
        return Py_None;
    }
    return NULL;
}
static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *typ;
    PyObject *tb = NULL;
    PyObject *val = NULL;
    PyObject *yf = gen->yieldfrom;
    if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
        return NULL;
    if (unlikely(__Pyx_Coroutine_CheckRunning(gen)))
        return NULL;
    if (yf) {
        PyObject *ret;
        Py_INCREF(yf);
        if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit)) {
            int err = __Pyx_Coroutine_CloseIter(gen, yf);
            Py_DECREF(yf);
            __Pyx_Coroutine_Undelegate(gen);
            if (err < 0)
                return __Pyx_Coroutine_MethodReturn(__Pyx_Coroutine_SendEx(gen, NULL));
            goto throw_here;
        }
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Throw(yf, args);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Throw(yf, args);
        } else
        #endif
        {
            PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
            if (unlikely(!meth)) {
                Py_DECREF(yf);
                if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                    gen->is_running = 0;
                    return NULL;
                }
                PyErr_Clear();
                __Pyx_Coroutine_Undelegate(gen);
                gen->is_running = 0;
                goto throw_here;
            }
            ret = PyObject_CallObject(meth, args);
            Py_DECREF(meth);
        }
        gen->is_running = 0;
        Py_DECREF(yf);
        if (!ret) {
            ret = __Pyx_Coroutine_FinishDelegation(gen);
        }
        return __Pyx_Coroutine_MethodReturn(ret);
    }
throw_here:
    __Pyx_Raise(typ, val, tb, NULL);
    return __Pyx_Coroutine_MethodReturn(__Pyx_Coroutine_SendEx(gen, NULL));
}
static int __Pyx_Coroutine_traverse(PyObject *self, visitproc visit, void *arg) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    Py_VISIT(gen->closure);
    Py_VISIT(gen->classobj);
    Py_VISIT(gen->yieldfrom);
    Py_VISIT(gen->exc_type);
    Py_VISIT(gen->exc_value);
    Py_VISIT(gen->exc_traceback);
    return 0;
}
static int __Pyx_Coroutine_clear(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    Py_CLEAR(gen->closure);
    Py_CLEAR(gen->classobj);
    Py_CLEAR(gen->yieldfrom);
    Py_CLEAR(gen->exc_type);
    Py_CLEAR(gen->exc_value);
    Py_CLEAR(gen->exc_traceback);
    Py_CLEAR(gen->gi_name);
    Py_CLEAR(gen->gi_qualname);
    return 0;
}
static void __Pyx_Coroutine_dealloc(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject_GC_UnTrack(gen);
    if (gen->gi_weakreflist != NULL)
        PyObject_ClearWeakRefs(self);
    if (gen->resume_label > 0) {
        PyObject_GC_Track(self);
#if PY_VERSION_HEX >= 0x030400a1
        if (PyObject_CallFinalizerFromDealloc(self))
#else
        Py_TYPE(gen)->tp_del(self);
        if (self->ob_refcnt > 0)
#endif
        {
            return;
        }
        PyObject_GC_UnTrack(self);
    }
    __Pyx_Coroutine_clear(self);
    PyObject_GC_Del(gen);
}
static void __Pyx_Coroutine_del(PyObject *self) {
    PyObject *res;
    PyObject *error_type, *error_value, *error_traceback;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    if (gen->resume_label <= 0)
        return ;
#if PY_VERSION_HEX < 0x030400a1
    assert(self->ob_refcnt == 0);
    self->ob_refcnt = 1;
#endif
    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
    res = __Pyx_Coroutine_Close(self);
    if (res == NULL)
        PyErr_WriteUnraisable(self);
    else
        Py_DECREF(res);
    __Pyx_ErrRestore(error_type, error_value, error_traceback);
#if PY_VERSION_HEX < 0x030400a1
    assert(self->ob_refcnt > 0);
    if (--self->ob_refcnt == 0) {
        return;
    }
    {
        Py_ssize_t refcnt = self->ob_refcnt;
        _Py_NewReference(self);
        self->ob_refcnt = refcnt;
    }
#if CYTHON_COMPILING_IN_CPYTHON
    assert(PyType_IS_GC(self->ob_type) &&
           _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
    _Py_DEC_REFTOTAL;
#endif
#ifdef COUNT_ALLOCS
    --Py_TYPE(self)->tp_frees;
    --Py_TYPE(self)->tp_allocs;
#endif
#endif
}
static PyObject *
__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self)
{
    Py_INCREF(self->gi_name);
    return self->gi_name;
}
static int
__Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_name;
    Py_INCREF(value);
    self->gi_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self)
{
    Py_INCREF(self->gi_qualname);
    return self->gi_qualname;
}
static int
__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_qualname;
    Py_INCREF(value);
    self->gi_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static __pyx_CoroutineObject *__Pyx__Coroutine_New(PyTypeObject* type, __pyx_coroutine_body_t body,
                                                   PyObject *closure, PyObject *name, PyObject *qualname) {
    __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
    if (gen == NULL)
        return NULL;
    gen->body = body;
    gen->closure = closure;
    Py_XINCREF(closure);
    gen->is_running = 0;
    gen->resume_label = 0;
    gen->classobj = NULL;
    gen->yieldfrom = NULL;
    gen->exc_type = NULL;
    gen->exc_value = NULL;
    gen->exc_traceback = NULL;
    gen->gi_weakreflist = NULL;
    Py_XINCREF(qualname);
    gen->gi_qualname = qualname;
    Py_XINCREF(name);
    gen->gi_name = name;
    PyObject_GC_Track(gen);
    return gen;
}

static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    int result;
    PyObject *globals, *result_obj;
    globals = PyDict_New();  if (unlikely(!globals)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_coroutine_type",
    #ifdef __Pyx_Coroutine_USED
        (PyObject*)__pyx_CoroutineType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_generator_type",
    #ifdef __Pyx_Generator_USED
        (PyObject*)__pyx_GeneratorType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
    result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
    if (unlikely(!result_obj)) goto ignore;
    Py_DECREF(result_obj);
    Py_DECREF(globals);
    return module;
ignore:
    Py_XDECREF(globals);
    PyErr_WriteUnraisable(module);
    if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
        Py_DECREF(module);
        module = NULL;
    }
#else
    py_code++;
#endif
    return module;
}

static int __Pyx_patch_abc(void) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    static int abc_patched = 0;
    if (!abc_patched) {
        PyObject *module;
        module = PyImport_ImportModule((PY_VERSION_HEX >= 0x03030000) ? "collections.abc" : "collections");
        if (!module) {
            PyErr_WriteUnraisable(NULL);
            if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
                    ((PY_VERSION_HEX >= 0x03030000) ?
                        "Cython module failed to register with collections.abc module" :
                        "Cython module failed to register with collections module"), 1) < 0)) {
                return -1;
            }
        } else {
            module = __Pyx_Coroutine_patch_module(
                module, ""
"if _cython_generator_type is not None:\n"
"    try: Generator = _module.Generator\n"
"    except AttributeError: pass\n"
"    else: Generator.register(_cython_generator_type)\n"
"if _cython_coroutine_type is not None:\n"
"    try: Coroutine = _module.Coroutine\n"
"    except AttributeError: pass\n"
"    else: Coroutine.register(_cython_coroutine_type)\n"
            );
            abc_patched = 1;
            if (unlikely(!module))
                return -1;
            Py_DECREF(module);
        }
    }
#else
    if (0) __Pyx_Coroutine_patch_module(NULL, NULL);
#endif
    return 0;
}

static PyMethodDef __pyx_Generator_methods[] = {
    {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
     (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
    {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
     (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
    {"close", (PyCFunction) __Pyx_Coroutine_Close, METH_NOARGS,
     (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
    {0, 0, 0, 0}
};
static PyMemberDef __pyx_Generator_memberlist[] = {
    {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
    {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
     (char*) PyDoc_STR("object being iterated by 'yield from', or None")},
    {0, 0, 0, 0, 0}
};
static PyGetSetDef __pyx_Generator_getsets[] = {
    {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
     (char*) PyDoc_STR("name of the generator"), 0},
    {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
     (char*) PyDoc_STR("qualified name of the generator"), 0},
    {0, 0, 0, 0, 0}
};
static PyTypeObject __pyx_GeneratorType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "generator",
    sizeof(__pyx_CoroutineObject),
    0,
    (destructor) __Pyx_Coroutine_dealloc,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
    0,
    (traverseproc) __Pyx_Coroutine_traverse,
    0,
    0,
    offsetof(__pyx_CoroutineObject, gi_weakreflist),
    0,
    (iternextfunc) __Pyx_Generator_Next,
    __pyx_Generator_methods,
    __pyx_Generator_memberlist,
    __pyx_Generator_getsets,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#else
    __Pyx_Coroutine_del,
#endif
    0,
#if PY_VERSION_HEX >= 0x030400a1
    __Pyx_Coroutine_del,
#endif
};
static int __pyx_Generator_init(void) {
    __pyx_GeneratorType_type.tp_getattro = PyObject_GenericGetAttr;
    __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
    __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
    if (unlikely(!__pyx_GeneratorType)) {
        return -1;
    }
    return 0;
}

static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;
    py_name = __Pyx_PyIdentifier_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    py_name = __Pyx_PyIdentifier_FromString(class_name);
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if (!strict && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    else if ((size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C function %.200s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
#if PY_VERSION_HEX < 0x03030000
        char* defenc_c;
        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
        if (!defenc) return NULL;
        defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        {
            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
            char* c;
            for (c = defenc_c; c < end; c++) {
                if ((unsigned char) (*c) >= 128) {
                    PyUnicode_AsASCIIString(o);
                    return NULL;
                }
            }
        }
#endif
        *length = PyBytes_GET_SIZE(defenc);
        return defenc_c;
#else
        if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        if (PyUnicode_IS_ASCII(o)) {
            *length = PyUnicode_GET_LENGTH(o);
            return PyUnicode_AsUTF8(o);
        } else {
            PyUnicode_AsASCIIString(o);
            return NULL;
        }
#else
        return PyUnicode_AsUTF8AndSize(o, length);
#endif
#endif
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return __Pyx_NewRef(x);
  m = Py_TYPE(x)->tp_as_number;
#if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_MAJOR_VERSION < 3
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%.4s__ returned non-%.4s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(x);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
