Repository: sympy/sympy

Issue:
Multivariate random symbol raises exception if name is "N"
```python
In [1]: from sympy.stats import *

In [2]: N = Normal("N", 2, 1)

In [3]: N = Normal("N1", [1,2], [[1,2],[2,5]])

In [4]: N = Normal("N", [1,2], [[1,2],[2,5]])
---------------------------------------------------------------------------
SympifyError: Sympify of expression 'could not parse '<function N at 0x7faccd50dd90>'' failed, because of exception being raised:
SyntaxError: invalid syntax (<string>, line 1)
```

Input 4 should behave exactly like input 3.

Discussion:

Patch:
diff --git a/sympy/stats/joint_rv.py b/sympy/stats/joint_rv.py
index b6884cee44..8d31e7a028 100644
--- a/sympy/stats/joint_rv.py
+++ b/sympy/stats/joint_rv.py
@@ -23,6 +23,7 @@
     SingleContinuousDistribution, SingleContinuousPSpace)
 from sympy.stats.drv import (DiscreteDistribution,
     SingleDiscreteDistribution, SingleDiscretePSpace)
+from sympy.core.compatibility import string_types
 from sympy.matrices import ImmutableMatrix
 from sympy.core.containers import Tuple
 from sympy.utilities.misc import filldedent
@@ -34,11 +35,14 @@ class JointPSpace(ProductPSpace):
     each component and a distribution.
     """
     def __new__(cls, sym, dist):
-        sym = sympify(sym)
         if isinstance(dist, SingleContinuousDistribution):
             return SingleContinuousPSpace(sym, dist)
         if isinstance(dist, SingleDiscreteDistribution):
             return SingleDiscretePSpace(sym, dist)
+        if isinstance(sym, string_types):
+            sym = Symbol(sym)
+        if not isinstance(sym, Symbol):
+            raise TypeError("s should have been string or Symbol")
         return Basic.__new__(cls, sym, dist)
 
     @property
diff --git a/sympy/stats/joint_rv_types.py b/sympy/stats/joint_rv_types.py
index d1e1b7fd18..490a4cc729 100644
--- a/sympy/stats/joint_rv_types.py
+++ b/sympy/stats/joint_rv_types.py
@@ -13,7 +13,6 @@
 # ]
 
 def multivariate_rv(cls, sym, *args):
-    sym = sympify(sym)
     args = list(map(sympify, args))
     dist = cls(*args)
     args = dist.args


Test patch:
diff --git a/sympy/stats/tests/test_joint_rv.py b/sympy/stats/tests/test_joint_rv.py
index 0af7b30b4f..c2216dc732 100644
--- a/sympy/stats/tests/test_joint_rv.py
+++ b/sympy/stats/tests/test_joint_rv.py
@@ -18,8 +18,8 @@ def test_Normal():
     assert density(m)(x, y) == density(p)(x, y)
     assert marginal_distribution(n, 0, 1)(1, 2) == 1/(2*pi)
     assert integrate(density(m)(x, y), (x, -oo, oo), (y, -oo, oo)).evalf() == 1
-    N1 = Normal('N1', [1, 2], [[x, 0], [0, y]])
-    assert density(N1)(0, 0) == exp(-2/y - 1/(2*x))/(2*pi*sqrt(x*y))
+    N = Normal('N', [1, 2], [[x, 0], [0, y]])
+    assert density(N)(0, 0) == exp(-2/y - 1/(2*x))/(2*pi*sqrt(x*y))
 
     raises (ValueError, lambda: Normal('M', [1, 2], [[1, 1], [1, -1]]))