passagemath-objects 10.6.44__cp314-cp314t-macosx_13_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. passagemath_objects/.dylibs/libgmp.10.dylib +0 -0
  2. passagemath_objects/__init__.py +3 -0
  3. passagemath_objects-10.6.44.dist-info/METADATA +115 -0
  4. passagemath_objects-10.6.44.dist-info/RECORD +280 -0
  5. passagemath_objects-10.6.44.dist-info/WHEEL +6 -0
  6. passagemath_objects-10.6.44.dist-info/top_level.txt +3 -0
  7. sage/all__sagemath_objects.py +37 -0
  8. sage/arith/all__sagemath_objects.py +5 -0
  9. sage/arith/long.pxd +411 -0
  10. sage/arith/numerical_approx.cpython-314t-darwin.so +0 -0
  11. sage/arith/numerical_approx.pxd +35 -0
  12. sage/arith/numerical_approx.pyx +75 -0
  13. sage/arith/power.cpython-314t-darwin.so +0 -0
  14. sage/arith/power.pxd +31 -0
  15. sage/arith/power.pyx +127 -0
  16. sage/categories/action.cpython-314t-darwin.so +0 -0
  17. sage/categories/action.pxd +29 -0
  18. sage/categories/action.pyx +641 -0
  19. sage/categories/algebra_functor.py +745 -0
  20. sage/categories/all__sagemath_objects.py +33 -0
  21. sage/categories/basic.py +62 -0
  22. sage/categories/cartesian_product.py +295 -0
  23. sage/categories/category.py +3401 -0
  24. sage/categories/category_cy_helper.cpython-314t-darwin.so +0 -0
  25. sage/categories/category_cy_helper.pxd +8 -0
  26. sage/categories/category_cy_helper.pyx +322 -0
  27. sage/categories/category_singleton.cpython-314t-darwin.so +0 -0
  28. sage/categories/category_singleton.pxd +3 -0
  29. sage/categories/category_singleton.pyx +342 -0
  30. sage/categories/category_types.py +637 -0
  31. sage/categories/category_with_axiom.py +2876 -0
  32. sage/categories/covariant_functorial_construction.py +703 -0
  33. sage/categories/facade_sets.py +228 -0
  34. sage/categories/functor.cpython-314t-darwin.so +0 -0
  35. sage/categories/functor.pxd +7 -0
  36. sage/categories/functor.pyx +691 -0
  37. sage/categories/homset.py +1338 -0
  38. sage/categories/homsets.py +364 -0
  39. sage/categories/isomorphic_objects.py +73 -0
  40. sage/categories/map.cpython-314t-darwin.so +0 -0
  41. sage/categories/map.pxd +34 -0
  42. sage/categories/map.pyx +2106 -0
  43. sage/categories/morphism.cpython-314t-darwin.so +0 -0
  44. sage/categories/morphism.pxd +14 -0
  45. sage/categories/morphism.pyx +895 -0
  46. sage/categories/objects.py +167 -0
  47. sage/categories/primer.py +1696 -0
  48. sage/categories/pushout.py +4834 -0
  49. sage/categories/quotients.py +64 -0
  50. sage/categories/realizations.py +200 -0
  51. sage/categories/sets_cat.py +3290 -0
  52. sage/categories/sets_with_partial_maps.py +52 -0
  53. sage/categories/subobjects.py +64 -0
  54. sage/categories/subquotients.py +21 -0
  55. sage/categories/with_realizations.py +311 -0
  56. sage/cpython/__init__.py +19 -0
  57. sage/cpython/_py2_random.py +619 -0
  58. sage/cpython/all.py +3 -0
  59. sage/cpython/atexit.cpython-314t-darwin.so +0 -0
  60. sage/cpython/atexit.pyx +269 -0
  61. sage/cpython/builtin_types.cpython-314t-darwin.so +0 -0
  62. sage/cpython/builtin_types.pyx +7 -0
  63. sage/cpython/cython_metaclass.cpython-314t-darwin.so +0 -0
  64. sage/cpython/cython_metaclass.h +117 -0
  65. sage/cpython/cython_metaclass.pxd +3 -0
  66. sage/cpython/cython_metaclass.pyx +130 -0
  67. sage/cpython/debug.cpython-314t-darwin.so +0 -0
  68. sage/cpython/debug.pyx +302 -0
  69. sage/cpython/dict_del_by_value.cpython-314t-darwin.so +0 -0
  70. sage/cpython/dict_del_by_value.pxd +9 -0
  71. sage/cpython/dict_del_by_value.pyx +191 -0
  72. sage/cpython/dict_internal.h +245 -0
  73. sage/cpython/getattr.cpython-314t-darwin.so +0 -0
  74. sage/cpython/getattr.pxd +9 -0
  75. sage/cpython/getattr.pyx +439 -0
  76. sage/cpython/pycore_long.h +97 -0
  77. sage/cpython/pycore_long.pxd +10 -0
  78. sage/cpython/python_debug.h +44 -0
  79. sage/cpython/python_debug.pxd +47 -0
  80. sage/cpython/pyx_visit.h +13 -0
  81. sage/cpython/string.cpython-314t-darwin.so +0 -0
  82. sage/cpython/string.pxd +76 -0
  83. sage/cpython/string.pyx +34 -0
  84. sage/cpython/string_impl.h +60 -0
  85. sage/cpython/type.cpython-314t-darwin.so +0 -0
  86. sage/cpython/type.pxd +2 -0
  87. sage/cpython/type.pyx +40 -0
  88. sage/cpython/wrapperdescr.pxd +67 -0
  89. sage/ext/all__sagemath_objects.py +3 -0
  90. sage/ext/ccobject.h +64 -0
  91. sage/ext/cplusplus.pxd +17 -0
  92. sage/ext/mod_int.h +30 -0
  93. sage/ext/mod_int.pxd +24 -0
  94. sage/ext/stdsage.pxd +39 -0
  95. sage/groups/all__sagemath_objects.py +1 -0
  96. sage/groups/group.cpython-314t-darwin.so +0 -0
  97. sage/groups/group.pxd +14 -0
  98. sage/groups/group.pyx +322 -0
  99. sage/groups/old.cpython-314t-darwin.so +0 -0
  100. sage/groups/old.pxd +14 -0
  101. sage/groups/old.pyx +219 -0
  102. sage/libs/all__sagemath_objects.py +3 -0
  103. sage/libs/gmp/__init__.py +1 -0
  104. sage/libs/gmp/all.pxd +6 -0
  105. sage/libs/gmp/binop.pxd +23 -0
  106. sage/libs/gmp/misc.pxd +8 -0
  107. sage/libs/gmp/mpf.pxd +88 -0
  108. sage/libs/gmp/mpn.pxd +57 -0
  109. sage/libs/gmp/mpq.pxd +57 -0
  110. sage/libs/gmp/mpz.pxd +202 -0
  111. sage/libs/gmp/pylong.cpython-314t-darwin.so +0 -0
  112. sage/libs/gmp/pylong.pxd +12 -0
  113. sage/libs/gmp/pylong.pyx +150 -0
  114. sage/libs/gmp/random.pxd +25 -0
  115. sage/libs/gmp/randomize.pxd +59 -0
  116. sage/libs/gmp/types.pxd +53 -0
  117. sage/libs/gmpxx.pxd +19 -0
  118. sage/misc/abstract_method.py +276 -0
  119. sage/misc/all__sagemath_objects.py +43 -0
  120. sage/misc/bindable_class.py +253 -0
  121. sage/misc/c3_controlled.cpython-314t-darwin.so +0 -0
  122. sage/misc/c3_controlled.pxd +2 -0
  123. sage/misc/c3_controlled.pyx +1402 -0
  124. sage/misc/cachefunc.cpython-314t-darwin.so +0 -0
  125. sage/misc/cachefunc.pxd +43 -0
  126. sage/misc/cachefunc.pyx +3781 -0
  127. sage/misc/call.py +188 -0
  128. sage/misc/classcall_metaclass.cpython-314t-darwin.so +0 -0
  129. sage/misc/classcall_metaclass.pxd +14 -0
  130. sage/misc/classcall_metaclass.pyx +599 -0
  131. sage/misc/constant_function.cpython-314t-darwin.so +0 -0
  132. sage/misc/constant_function.pyx +130 -0
  133. sage/misc/decorators.py +747 -0
  134. sage/misc/fast_methods.cpython-314t-darwin.so +0 -0
  135. sage/misc/fast_methods.pxd +20 -0
  136. sage/misc/fast_methods.pyx +351 -0
  137. sage/misc/flatten.py +90 -0
  138. sage/misc/fpickle.cpython-314t-darwin.so +0 -0
  139. sage/misc/fpickle.pyx +177 -0
  140. sage/misc/function_mangling.cpython-314t-darwin.so +0 -0
  141. sage/misc/function_mangling.pxd +11 -0
  142. sage/misc/function_mangling.pyx +308 -0
  143. sage/misc/inherit_comparison.cpython-314t-darwin.so +0 -0
  144. sage/misc/inherit_comparison.pxd +5 -0
  145. sage/misc/inherit_comparison.pyx +105 -0
  146. sage/misc/instancedoc.cpython-314t-darwin.so +0 -0
  147. sage/misc/instancedoc.pyx +331 -0
  148. sage/misc/lazy_attribute.cpython-314t-darwin.so +0 -0
  149. sage/misc/lazy_attribute.pyx +607 -0
  150. sage/misc/lazy_format.py +135 -0
  151. sage/misc/lazy_import.cpython-314t-darwin.so +0 -0
  152. sage/misc/lazy_import.pyx +1299 -0
  153. sage/misc/lazy_import_cache.py +36 -0
  154. sage/misc/lazy_list.cpython-314t-darwin.so +0 -0
  155. sage/misc/lazy_list.pxd +19 -0
  156. sage/misc/lazy_list.pyx +1187 -0
  157. sage/misc/lazy_string.cpython-314t-darwin.so +0 -0
  158. sage/misc/lazy_string.pxd +7 -0
  159. sage/misc/lazy_string.pyx +546 -0
  160. sage/misc/misc.py +1066 -0
  161. sage/misc/misc_c.cpython-314t-darwin.so +0 -0
  162. sage/misc/misc_c.pxd +3 -0
  163. sage/misc/misc_c.pyx +766 -0
  164. sage/misc/namespace_package.py +37 -0
  165. sage/misc/nested_class.cpython-314t-darwin.so +0 -0
  166. sage/misc/nested_class.pxd +3 -0
  167. sage/misc/nested_class.pyx +394 -0
  168. sage/misc/persist.cpython-314t-darwin.so +0 -0
  169. sage/misc/persist.pyx +1251 -0
  170. sage/misc/prandom.py +418 -0
  171. sage/misc/randstate.cpython-314t-darwin.so +0 -0
  172. sage/misc/randstate.pxd +30 -0
  173. sage/misc/randstate.pyx +1059 -0
  174. sage/misc/repr.py +203 -0
  175. sage/misc/reset.cpython-314t-darwin.so +0 -0
  176. sage/misc/reset.pyx +196 -0
  177. sage/misc/sage_ostools.cpython-314t-darwin.so +0 -0
  178. sage/misc/sage_ostools.pyx +323 -0
  179. sage/misc/sage_timeit.py +275 -0
  180. sage/misc/sage_timeit_class.cpython-314t-darwin.so +0 -0
  181. sage/misc/sage_timeit_class.pyx +120 -0
  182. sage/misc/sage_unittest.py +637 -0
  183. sage/misc/sageinspect.py +2768 -0
  184. sage/misc/session.cpython-314t-darwin.so +0 -0
  185. sage/misc/session.pyx +392 -0
  186. sage/misc/superseded.py +557 -0
  187. sage/misc/test_nested_class.py +228 -0
  188. sage/misc/timing.py +264 -0
  189. sage/misc/unknown.py +222 -0
  190. sage/misc/verbose.py +253 -0
  191. sage/misc/weak_dict.cpython-314t-darwin.so +0 -0
  192. sage/misc/weak_dict.pxd +15 -0
  193. sage/misc/weak_dict.pyx +1231 -0
  194. sage/modules/all__sagemath_objects.py +1 -0
  195. sage/modules/module.cpython-314t-darwin.so +0 -0
  196. sage/modules/module.pxd +5 -0
  197. sage/modules/module.pyx +329 -0
  198. sage/rings/all__sagemath_objects.py +3 -0
  199. sage/rings/integer_fake.h +22 -0
  200. sage/rings/integer_fake.pxd +55 -0
  201. sage/sets/all__sagemath_objects.py +3 -0
  202. sage/sets/pythonclass.cpython-314t-darwin.so +0 -0
  203. sage/sets/pythonclass.pxd +9 -0
  204. sage/sets/pythonclass.pyx +247 -0
  205. sage/structure/__init__.py +4 -0
  206. sage/structure/all.py +30 -0
  207. sage/structure/category_object.cpython-314t-darwin.so +0 -0
  208. sage/structure/category_object.pxd +28 -0
  209. sage/structure/category_object.pyx +1087 -0
  210. sage/structure/coerce.cpython-314t-darwin.so +0 -0
  211. sage/structure/coerce.pxd +44 -0
  212. sage/structure/coerce.pyx +2107 -0
  213. sage/structure/coerce_actions.cpython-314t-darwin.so +0 -0
  214. sage/structure/coerce_actions.pxd +27 -0
  215. sage/structure/coerce_actions.pyx +988 -0
  216. sage/structure/coerce_dict.cpython-314t-darwin.so +0 -0
  217. sage/structure/coerce_dict.pxd +51 -0
  218. sage/structure/coerce_dict.pyx +1557 -0
  219. sage/structure/coerce_exceptions.py +23 -0
  220. sage/structure/coerce_maps.cpython-314t-darwin.so +0 -0
  221. sage/structure/coerce_maps.pxd +28 -0
  222. sage/structure/coerce_maps.pyx +718 -0
  223. sage/structure/debug_options.cpython-314t-darwin.so +0 -0
  224. sage/structure/debug_options.pxd +6 -0
  225. sage/structure/debug_options.pyx +54 -0
  226. sage/structure/dynamic_class.py +541 -0
  227. sage/structure/element.cpython-314t-darwin.so +0 -0
  228. sage/structure/element.pxd +272 -0
  229. sage/structure/element.pyx +4772 -0
  230. sage/structure/element_wrapper.cpython-314t-darwin.so +0 -0
  231. sage/structure/element_wrapper.pxd +12 -0
  232. sage/structure/element_wrapper.pyx +582 -0
  233. sage/structure/factorization.py +1422 -0
  234. sage/structure/factorization_integer.py +105 -0
  235. sage/structure/factory.cpython-314t-darwin.so +0 -0
  236. sage/structure/factory.pyx +786 -0
  237. sage/structure/formal_sum.py +489 -0
  238. sage/structure/gens_py.py +73 -0
  239. sage/structure/global_options.py +1743 -0
  240. sage/structure/indexed_generators.py +863 -0
  241. sage/structure/list_clone.cpython-314t-darwin.so +0 -0
  242. sage/structure/list_clone.pxd +65 -0
  243. sage/structure/list_clone.pyx +1867 -0
  244. sage/structure/list_clone_demo.cpython-314t-darwin.so +0 -0
  245. sage/structure/list_clone_demo.pyx +248 -0
  246. sage/structure/list_clone_timings.py +179 -0
  247. sage/structure/list_clone_timings_cy.cpython-314t-darwin.so +0 -0
  248. sage/structure/list_clone_timings_cy.pyx +86 -0
  249. sage/structure/mutability.cpython-314t-darwin.so +0 -0
  250. sage/structure/mutability.pxd +21 -0
  251. sage/structure/mutability.pyx +348 -0
  252. sage/structure/nonexact.py +69 -0
  253. sage/structure/parent.cpython-314t-darwin.so +0 -0
  254. sage/structure/parent.pxd +112 -0
  255. sage/structure/parent.pyx +3093 -0
  256. sage/structure/parent_base.cpython-314t-darwin.so +0 -0
  257. sage/structure/parent_base.pxd +13 -0
  258. sage/structure/parent_base.pyx +44 -0
  259. sage/structure/parent_gens.cpython-314t-darwin.so +0 -0
  260. sage/structure/parent_gens.pxd +22 -0
  261. sage/structure/parent_gens.pyx +377 -0
  262. sage/structure/parent_old.cpython-314t-darwin.so +0 -0
  263. sage/structure/parent_old.pxd +25 -0
  264. sage/structure/parent_old.pyx +294 -0
  265. sage/structure/proof/__init__.py +1 -0
  266. sage/structure/proof/all.py +243 -0
  267. sage/structure/proof/proof.py +300 -0
  268. sage/structure/richcmp.cpython-314t-darwin.so +0 -0
  269. sage/structure/richcmp.pxd +213 -0
  270. sage/structure/richcmp.pyx +495 -0
  271. sage/structure/sage_object.cpython-314t-darwin.so +0 -0
  272. sage/structure/sage_object.pxd +3 -0
  273. sage/structure/sage_object.pyx +988 -0
  274. sage/structure/sage_object_test.py +19 -0
  275. sage/structure/sequence.py +937 -0
  276. sage/structure/set_factories.py +1178 -0
  277. sage/structure/set_factories_example.py +527 -0
  278. sage/structure/support_view.py +179 -0
  279. sage/structure/test_factory.py +56 -0
  280. sage/structure/unique_representation.py +1359 -0
sage/misc/prandom.py ADDED
@@ -0,0 +1,418 @@
1
+ # sage_setup: distribution = sagemath-objects
2
+ r"""
3
+ Random Numbers with Python API
4
+
5
+ AUTHORS:
6
+ -- Carl Witty (2008-03): new file
7
+
8
+ This module has the same functions as the Python standard module
9
+ \module{random}, but uses the current \sage random number state from
10
+ \module{sage.misc.randstate} (so that it can be controlled by the same
11
+ global random number seeds).
12
+
13
+ The functions here are less efficient than the functions in \module{random},
14
+ because they look up the current random number state on each call.
15
+
16
+ If you are going to be creating many random numbers in a row, it is
17
+ better to use the functions in \module{sage.misc.randstate} directly.
18
+
19
+ Here is an example:
20
+
21
+ (The imports on the next two lines are not necessary, since
22
+ \function{randrange} and \function{current_randstate} are both available
23
+ by default at the \code{sage:} prompt; but you would need them
24
+ to run these examples inside a module.) ::
25
+
26
+ sage: from sage.misc.prandom import randrange
27
+ sage: from sage.misc.randstate import current_randstate
28
+ sage: def test1():
29
+ ....: return sum([randrange(100) for i in range(100)])
30
+ sage: def test2():
31
+ ....: randrange = current_randstate().python_random().randrange
32
+ ....: return sum([randrange(100) for i in range(100)])
33
+
34
+ Test2 will be slightly faster than test1, but they give the same answer::
35
+
36
+ sage: with seed(0): test1()
37
+ 5169
38
+ sage: with seed(0): test2()
39
+ 5169
40
+ sage: with seed(1): test1()
41
+ 5097
42
+ sage: with seed(1): test2()
43
+ 5097
44
+ sage: timeit('test1()') # random
45
+ 625 loops, best of 3: 590 us per loop
46
+ sage: timeit('test2()') # random
47
+ 625 loops, best of 3: 460 us per loop
48
+
49
+ The docstrings for the functions in this file are mostly copied from
50
+ Python's \file{random.py}, so those docstrings are "Copyright (c)
51
+ 2001, 2002, 2003, 2004, 2005, 2006, 2007 Python Software Foundation;
52
+ All Rights Reserved" and are available under the terms of the
53
+ Python Software Foundation License Version 2.
54
+ """
55
+
56
+ # We deliberately omit "seed" and several other seed-related functions...
57
+ # setting seeds should only be done through sage.misc.randstate .
58
+
59
+ from sage.misc.randstate import current_randstate
60
+
61
+
62
+ def _pyrand():
63
+ r"""
64
+ A tiny private helper function to return an instance of
65
+ random.Random from the current \sage random number state.
66
+ Only for use in prandom.py; other modules should use
67
+ current_randstate().python_random().
68
+
69
+ EXAMPLES::
70
+
71
+ sage: set_random_seed(0)
72
+ sage: from sage.misc.prandom import _pyrand
73
+ sage: _pyrand()
74
+ <...random.Random object at 0x...>
75
+ sage: _pyrand().getrandbits(int(10))
76
+ 114
77
+ """
78
+ return current_randstate().python_random()
79
+
80
+
81
+ def getrandbits(k):
82
+ r"""
83
+ getrandbits(k) -> x. Generates a long int with k random bits.
84
+
85
+ EXAMPLES::
86
+
87
+ sage: getrandbits(10) in range(2^10)
88
+ True
89
+ sage: getrandbits(200) in range(2^200)
90
+ True
91
+ sage: getrandbits(4) in range(2^4)
92
+ True
93
+ """
94
+ return _pyrand().getrandbits(int(k))
95
+
96
+
97
+ def randrange(start, stop=None, step=1):
98
+ r"""
99
+ Choose a random item from range(start, stop[, step]).
100
+
101
+ This fixes the problem with randint() which includes the
102
+ endpoint; in Python this is usually not what you want.
103
+
104
+ EXAMPLES::
105
+
106
+ sage: s = randrange(0, 100, 11)
107
+ sage: 0 <= s < 100
108
+ True
109
+ sage: s % 11
110
+ 0
111
+
112
+ sage: 5000 <= randrange(5000, 5100) < 5100
113
+ True
114
+ sage: s = [randrange(0, 2) for i in range(15)]
115
+ sage: all(t in [0, 1] for t in s)
116
+ True
117
+
118
+ sage: s = randrange(0, 1000000, 1000)
119
+ sage: 0 <= s < 1000000
120
+ True
121
+ sage: s % 1000
122
+ 0
123
+ sage: -100 <= randrange(-100, 10) < 10
124
+ True
125
+ """
126
+ return _pyrand().randrange(start, stop, step)
127
+
128
+
129
+ def randint(a, b):
130
+ r"""
131
+ Return random integer in range [a, b], including both end points.
132
+
133
+ EXAMPLES::
134
+
135
+ sage: s = [randint(0, 2) for i in range(15)]; s # random
136
+ [0, 1, 0, 0, 1, 0, 2, 0, 2, 1, 2, 2, 0, 2, 2]
137
+ sage: all(t in [0, 1, 2] for t in s)
138
+ True
139
+ sage: -100 <= randint(-100, 10) <= 10
140
+ True
141
+ """
142
+ return _pyrand().randint(a, b)
143
+
144
+
145
+ def choice(seq):
146
+ r"""
147
+ Choose a random element from a non-empty sequence.
148
+
149
+ EXAMPLES::
150
+
151
+ sage: s = [choice(list(primes(10, 100))) for i in range(5)]; s # random # needs sage.libs.pari
152
+ [17, 47, 11, 31, 47]
153
+ sage: all(t in primes(10, 100) for t in s) # needs sage.libs.pari
154
+ True
155
+ """
156
+ return _pyrand().choice(seq)
157
+
158
+
159
+ def shuffle(x):
160
+ r"""
161
+ x, random=random.random -> shuffle list x in place; return None.
162
+
163
+ Optional arg random is a 0-argument function returning a random
164
+ float in [0.0, 1.0); by default, the sage.misc.random.random.
165
+
166
+ EXAMPLES::
167
+
168
+ sage: shuffle([1 .. 10])
169
+ """
170
+ return _pyrand().shuffle(x)
171
+
172
+
173
+ def sample(population, k):
174
+ r"""
175
+ Choose k unique random elements from a population sequence.
176
+
177
+ Return a new list containing elements from the population while
178
+ leaving the original population unchanged. The resulting list is
179
+ in selection order so that all sub-slices will also be valid random
180
+ samples. This allows raffle winners (the sample) to be partitioned
181
+ into grand prize and second place winners (the subslices).
182
+
183
+ Members of the population need not be hashable or unique. If the
184
+ population contains repeats, then each occurrence is a possible
185
+ selection in the sample.
186
+
187
+ To choose a sample in a range of integers, use xrange as an
188
+ argument (in Python 2) or range (in Python 3). This is especially
189
+ fast and space efficient for sampling from a large population:
190
+ sample(range(10000000), 60)
191
+
192
+ EXAMPLES::
193
+
194
+ sage: from sage.misc.misc import is_sublist
195
+ sage: l = ["Here", "I", "come", "to", "save", "the", "day"]
196
+ sage: s = sample(l, 3); s # random
197
+ ['Here', 'to', 'day']
198
+ sage: is_sublist(sorted(s), sorted(l))
199
+ True
200
+ sage: len(s)
201
+ 3
202
+
203
+ sage: s = sample(range(2^30), 7); s # random
204
+ [357009070, 558990255, 196187132, 752551188, 85926697, 954621491, 624802848]
205
+ sage: len(s)
206
+ 7
207
+ sage: all(t in range(2^30) for t in s)
208
+ True
209
+ """
210
+ return _pyrand().sample(population, k)
211
+
212
+
213
+ def random():
214
+ r"""
215
+ Get the next random number in the range [0.0, 1.0).
216
+
217
+ EXAMPLES::
218
+
219
+ sage: sample = [random() for i in [1 .. 4]]; sample # random
220
+ [0.111439293741037, 0.5143475134191677, 0.04468968524815642, 0.332490606442413]
221
+ sage: all(0.0 <= s <= 1.0 for s in sample)
222
+ True
223
+ """
224
+ return _pyrand().random()
225
+
226
+
227
+ def uniform(a, b):
228
+ r"""
229
+ Get a random number in the range [a, b).
230
+
231
+ Equivalent to \code{a + (b-a) * random()}.
232
+
233
+ EXAMPLES::
234
+
235
+ sage: s = uniform(0, 1); s # random
236
+ 0.111439293741037
237
+ sage: 0.0 <= s <= 1.0
238
+ True
239
+
240
+ sage: s = uniform(e, pi); s # random # needs sage.symbolic
241
+ 0.5143475134191677*pi + 0.48565248658083227*e
242
+ sage: bool(e <= s <= pi) # needs sage.symbolic
243
+ True
244
+ """
245
+ return _pyrand().uniform(a, b)
246
+
247
+
248
+ def betavariate(alpha, beta):
249
+ r"""
250
+ Beta distribution.
251
+
252
+ Conditions on the parameters are alpha > 0 and beta > 0.
253
+ Returned values range between 0 and 1.
254
+
255
+ EXAMPLES::
256
+
257
+ sage: s = betavariate(0.1, 0.9); s # random
258
+ 9.75087916621299e-9
259
+ sage: 0.0 <= s <= 1.0
260
+ True
261
+
262
+ sage: s = betavariate(0.9, 0.1); s # random
263
+ 0.941890400939253
264
+ sage: 0.0 <= s <= 1.0
265
+ True
266
+ """
267
+ return _pyrand().betavariate(alpha, beta)
268
+
269
+
270
+ def expovariate(lambd):
271
+ r"""
272
+ Exponential distribution.
273
+
274
+ lambd is 1.0 divided by the desired mean. (The parameter would be
275
+ called "lambda", but that is a reserved word in Python.) Returned
276
+ values range from 0 to positive infinity.
277
+
278
+ EXAMPLES::
279
+
280
+ sage: sample = [expovariate(0.001) for i in range(3)]; sample # random
281
+ [118.152309288166, 722.261959038118, 45.7190543690470]
282
+ sage: all(s >= 0.0 for s in sample)
283
+ True
284
+
285
+ sage: sample = [expovariate(1.0) for i in range(3)]; sample # random
286
+ [0.404201816061304, 0.735220464997051, 0.201765578600627]
287
+ sage: all(s >= 0.0 for s in sample)
288
+ True
289
+
290
+ sage: sample = [expovariate(1000) for i in range(3)]; sample # random
291
+ [0.0012068700332283973, 8.340929747302108e-05, 0.00219877067980605]
292
+ sage: all(s >= 0.0 for s in sample)
293
+ True
294
+ """
295
+ return _pyrand().expovariate(lambd)
296
+
297
+
298
+ def gammavariate(alpha, beta):
299
+ r"""
300
+ Gamma distribution. (Not the gamma function.)
301
+
302
+ Conditions on the parameters are alpha > 0 and beta > 0.
303
+
304
+ EXAMPLES::
305
+
306
+ sage: sample = gammavariate(1.0, 3.0); sample # random
307
+ 6.58282586130638
308
+ sage: sample > 0
309
+ True
310
+ sage: sample = gammavariate(3.0, 1.0); sample # random
311
+ 3.07801512341612
312
+ sage: sample > 0
313
+ True
314
+ """
315
+ return _pyrand().gammavariate(alpha, beta)
316
+
317
+
318
+ def gauss(mu, sigma):
319
+ r"""
320
+ Gaussian distribution.
321
+
322
+ mu is the mean, and sigma is the standard deviation. This is
323
+ slightly faster than the normalvariate() function, but is not
324
+ thread-safe.
325
+
326
+ EXAMPLES::
327
+
328
+ sage: [gauss(0, 1) for i in range(3)] # random
329
+ [0.9191011757657915, 0.7744526756246484, 0.8638996866800877]
330
+ sage: [gauss(0, 100) for i in range(3)] # random
331
+ [24.916051749154448, -62.99272061579273, -8.1993122536718...]
332
+ sage: [gauss(1000, 10) for i in range(3)] # random
333
+ [998.7590700045661, 996.1087338511692, 1010.1256817458031]
334
+ """
335
+ return _pyrand().gauss(mu, sigma)
336
+
337
+
338
+ def lognormvariate(mu, sigma):
339
+ r"""
340
+ Log normal distribution.
341
+
342
+ If you take the natural logarithm of this distribution, you'll get a
343
+ normal distribution with mean mu and standard deviation sigma.
344
+ mu can have any value, and sigma must be greater than zero.
345
+
346
+ EXAMPLES::
347
+
348
+ sage: [lognormvariate(100, 10) for i in range(3)] # random
349
+ [2.9410355688290246e+37, 2.2257548162070125e+38, 4.142299451717446e+43]
350
+ """
351
+ return _pyrand().lognormvariate(mu, sigma)
352
+
353
+
354
+ def normalvariate(mu, sigma):
355
+ r"""
356
+ Normal distribution.
357
+
358
+ mu is the mean, and sigma is the standard deviation.
359
+
360
+ EXAMPLES::
361
+
362
+ sage: [normalvariate(0, 1) for i in range(3)] # random
363
+ [-1.372558980559407, -1.1701670364898928, 0.04324100555110143]
364
+ sage: [normalvariate(0, 100) for i in range(3)] # random
365
+ [37.45695875041769, 159.6347743233298, 124.1029321124009]
366
+ sage: [normalvariate(1000, 10) for i in range(3)] # random
367
+ [1008.5303090383741, 989.8624892644895, 985.7728921150242]
368
+ """
369
+ return _pyrand().normalvariate(mu, sigma)
370
+
371
+
372
+ def vonmisesvariate(mu, kappa):
373
+ r"""
374
+ Circular data distribution.
375
+
376
+ mu is the mean angle, expressed in radians between 0 and 2*pi, and
377
+ kappa is the concentration parameter, which must be greater than or
378
+ equal to zero. If kappa is equal to zero, this distribution reduces
379
+ to a uniform random angle over the range 0 to 2*pi.
380
+
381
+ EXAMPLES::
382
+
383
+ sage: sample = [vonmisesvariate(1.0r, 3.0r) for i in range(1, 5)]; sample # random
384
+ [0.898328639355427, 0.6718030007041281, 2.0308777524813393, 1.714325253725145]
385
+ sage: all(s >= 0.0 for s in sample)
386
+ True
387
+ """
388
+ return _pyrand().vonmisesvariate(mu, kappa)
389
+
390
+
391
+ def paretovariate(alpha):
392
+ r"""
393
+ Pareto distribution. alpha is the shape parameter.
394
+
395
+ EXAMPLES::
396
+
397
+ sage: sample = [paretovariate(3) for i in range(1, 5)]; sample # random
398
+ [1.0401699394233033, 1.2722080162636495, 1.0153564009379579, 1.1442323078983077]
399
+ sage: all(s >= 1.0 for s in sample)
400
+ True
401
+ """
402
+ return _pyrand().paretovariate(alpha)
403
+
404
+
405
+ def weibullvariate(alpha, beta):
406
+ r"""
407
+ Weibull distribution.
408
+
409
+ alpha is the scale parameter and beta is the shape parameter.
410
+
411
+ EXAMPLES::
412
+
413
+ sage: sample = [weibullvariate(1, 3) for i in range(1, 5)]; sample # random
414
+ [0.49069775546342537, 0.8972185564611213, 0.357573846531942, 0.739377255516847]
415
+ sage: all(s >= 0.0 for s in sample)
416
+ True
417
+ """
418
+ return _pyrand().weibullvariate(alpha, beta)
@@ -0,0 +1,30 @@
1
+ # sage_setup: distribution = sagemath-objects
2
+ from sage.libs.gmp.types cimport gmp_randstate_t
3
+
4
+ # The c_random() method on randstate objects gives a value
5
+ # 0 <= n <= SAGE_RAND_MAX
6
+ cdef extern from *:
7
+ int SAGE_RAND_MAX "(0x7fffffff)" # 2^31 - 1
8
+
9
+
10
+ cdef class randstate:
11
+ cdef gmp_randstate_t gmp_state
12
+ cdef object _seed
13
+ cdef object _python_random
14
+
15
+ cdef object _gap_saved_seed
16
+ cdef object _pari_saved_seed
17
+
18
+ cdef object _gp_saved_seeds
19
+
20
+ cpdef set_seed_libc(self, bint force)
21
+ cpdef set_seed_ntl(self, bint force)
22
+
23
+ cpdef int c_random(self) noexcept
24
+ cpdef double c_rand_double(self) noexcept
25
+
26
+ cpdef ZZ_seed(self)
27
+ cpdef long_seed(self)
28
+
29
+ cpdef randstate current_randstate()
30
+ cpdef int random() noexcept