{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Only float types are supported for now."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "res",
              "annotation": "sparse matrix",
              "desc": []
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Generate a sparse matrix of the given shape and density with uniformly distributed values."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "m, n",
              "annotation": "int",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "shape of the matrix"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "density",
              "annotation": "real, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "density of the generated matrix: density equal to one means a full matrix, density of 0 means a matrix with no non-zero items."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "format",
              "annotation": "str, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "sparse matrix format."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "dtype",
              "annotation": "dtype, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "type of the returned matrix values."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "rng",
              "annotation": "{None, int, `numpy.random.Generator`}, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "rng"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is passed by keyword, types other than "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.random.Generator",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "*",
                        "kind": "api",
                        "path": "numpy.random._generator:Generator"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " are passed to "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.random.default_rng",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "*",
                        "kind": "api",
                        "path": "numpy.random:default_rng"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " to instantiate a "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "Generator"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". If "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "rng"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is already a "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "Generator"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " instance, then the provided instance is used. Specify "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "rng"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " for repeatable function behavior."
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If this argument is passed by position or "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "random_state"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is passed by keyword, legacy behavior for the argument "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "random_state"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " applies:"
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "If "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "random_state"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " is None (or "
                            },
                            {
                              "__type": "CrossRef",
                              "__tag": 4002,
                              "value": "numpy.random",
                              "reference": {
                                "__type": "RefInfo",
                                "__tag": 4000,
                                "module": "numpy",
                                "version": "*",
                                "kind": "api",
                                "path": "numpy.random"
                              },
                              "kind": "module"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "), the "
                            },
                            {
                              "__type": "CrossRef",
                              "__tag": 4002,
                              "value": "numpy.random.RandomState",
                              "reference": {
                                "__type": "RefInfo",
                                "__tag": 4000,
                                "module": "numpy",
                                "version": "*",
                                "kind": "api",
                                "path": "numpy.random.mtrand:RandomState"
                              },
                              "kind": "module"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "   singleton is used."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "If "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "random_state"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " is an int, a new "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "RandomState"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " instance is used,   seeded with "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "random_state"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "If "
                            },
                            {
                              "__type": "ParamRef",
                              "__tag": 4071,
                              "name": "random_state"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " is already a "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "Generator"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " or "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "RandomState"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " instance then   that instance is used."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "Admonition",
                  "__tag": 4056,
                  "kind": "versionchanged",
                  "base_type": "neutral",
                  "children": [
                    {
                      "__type": "AdmonitionTitle",
                      "__tag": 4055,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "versionchanged 1.15.0"
                        }
                      ]
                    },
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "As part of the "
                        },
                        {
                          "__type": "Link",
                          "__tag": 4049,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "SPEC-007"
                            }
                          ],
                          "url": "https://scientific-python.org/specs/spec-0007/",
                          "title": ""
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " transition from use of "
                        },
                        {
                          "__type": "CrossRef",
                          "__tag": 4002,
                          "value": "numpy.random.RandomState",
                          "reference": {
                            "__type": "RefInfo",
                            "__tag": 4000,
                            "module": "numpy",
                            "version": "*",
                            "kind": "api",
                            "path": "numpy.random.mtrand:RandomState"
                          },
                          "kind": "module"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " to "
                        },
                        {
                          "__type": "CrossRef",
                          "__tag": 4002,
                          "value": "numpy.random.Generator",
                          "reference": {
                            "__type": "RefInfo",
                            "__tag": 4000,
                            "module": "numpy",
                            "version": "*",
                            "kind": "api",
                            "path": "numpy.random._generator:Generator"
                          },
                          "kind": "module"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": ", this keyword was changed from "
                        },
                        {
                          "__type": "ParamRef",
                          "__tag": 4071,
                          "name": "random_state"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " to "
                        },
                        {
                          "__type": "ParamRef",
                          "__tag": 4071,
                          "name": "rng"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": ". For an interim period, both keywords will continue to work, although only one may be specified at a time. After the interim period, function calls using the "
                        },
                        {
                          "__type": "ParamRef",
                          "__tag": 4071,
                          "name": "random_state"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " keyword will emit warnings. The behavior of both "
                        },
                        {
                          "__type": "ParamRef",
                          "__tag": 4071,
                          "name": "random_state"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " and "
                        },
                        {
                          "__type": "ParamRef",
                          "__tag": 4071,
                          "name": "rng"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " are outlined above, but only the "
                        },
                        {
                          "__type": "ParamRef",
                          "__tag": 4071,
                          "name": "rng"
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " keyword should be used in new code."
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "warning",
          "base_type": "warning",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "warning "
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "This function returns a sparse matrix -- not a sparse array. You are encouraged to use "
                },
                {
                  "__type": "CrossRef",
                  "__tag": 4002,
                  "value": "random_array",
                  "reference": {
                    "__type": "LocalRef",
                    "__tag": 4022,
                    "kind": "module",
                    "path": "scipy.sparse._construct:random_array"
                  },
                  "kind": "module"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " to take advantage of the sparse array functionality."
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/scipy/sparse/_construct.py",
  "item_line": 1655,
  "item_type": "function",
  "aliases": [
    "scipy.sparse.rand"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.sparse import rand\nmatrix = rand(3, 4, density=0.25, format=\"csr\", rng=42)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "matrix\nmatrix.toarray()\n",
        "execution_status": "failure"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "random",
        "reference": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "current-module",
          "version": "current-version",
          "kind": "to-resolve",
          "path": "random"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Similar function allowing a custom random data sampler"
            }
          ]
        }
      ],
      "type": "func"
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "random_array",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.sparse._construct:random_array"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Similar to random() but returns a sparse array"
            }
          ]
        }
      ],
      "type": "func"
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "m",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "n",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "density",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "0.01"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "format",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "coo"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "dtype",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "rng",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "random_state",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "rand"
  },
  "references": null,
  "qa": "scipy.sparse._construct:rand",
  "arbitrary": [],
  "local_refs": [
    "density",
    "dtype",
    "format",
    "m",
    "n",
    "res",
    "rng"
  ]
}