diff --git a/pystencils/rng.py b/pystencils/rng.py
index c75c3f9727720d2d313adee3cda3eead520334c7..6e9bc95480cf83654ce4b4b0b7d783fbb0c6718b 100644
--- a/pystencils/rng.py
+++ b/pystencils/rng.py
@@ -61,6 +61,15 @@ class RNGBase(CustomCodeNode):
         return ", ".join([str(s) for s in self.result_symbols]) + " \\leftarrow " + \
             self._name.capitalize() + "_RNG(" + ", ".join([str(a) for a in self.args]) + ")"
 
+    def _hashable_content(self):
+        return (self._name, *self.result_symbols, *self.args)
+
+    def __eq__(self, other):
+        return type(self) == type(other) and self._hashable_content() == other._hashable_content()
+
+    def __hash__(self):
+        return hash(self._hashable_content())
+
 
 class PhiloxTwoDoubles(RNGBase):
     _name = "philox_double2"