Linux websever 5.15.0-153-generic #163-Ubuntu SMP Thu Aug 7 16:37:18 UTC 2025 x86_64
Apache/2.4.52 (Ubuntu)
: 192.168.3.70 | : 192.168.1.99
Cant Read [ /etc/named.conf ]
8.1.2-1ubuntu2.23
urlab
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
usr /
lib /
python3 /
dist-packages /
networkx /
utils /
[ HOME SHELL ]
Name
Size
Permission
Action
__pycache__
[ DIR ]
drwxr-xr-x
tests
[ DIR ]
drwxr-xr-x
__init__.py
272
B
-rw-r--r--
contextmanagers.py
593
B
-rw-r--r--
decorators.py
14.38
KB
-rw-r--r--
heaps.py
10.86
KB
-rw-r--r--
mapped_queue.py
6.15
KB
-rw-r--r--
misc.py
13.04
KB
-rw-r--r--
random_sequence.py
4.32
KB
-rw-r--r--
rcm.py
4.79
KB
-rw-r--r--
union_find.py
3.49
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : random_sequence.py
# Copyright (C) 2004-2019 by # Aric Hagberg <hagberg@lanl.gov> # Dan Schult <dschult@colgate.edu> # Pieter Swart <swart@lanl.gov> # All rights reserved. # BSD license. # # Authors: Aric Hagberg (hagberg@lanl.gov) # Dan Schult (dschult@colgate.edu) # Ben Edwards (bedwards@cs.unm.edu) """ Utilities for generating random numbers, random sequences, and random selections. """ import random import sys import networkx as nx from networkx.utils import py_random_state # The same helpers for choosing random sequences from distributions # uses Python's random module # https://docs.python.org/2/library/random.html @py_random_state(2) def powerlaw_sequence(n, exponent=2.0, seed=None): """ Return sample sequence of length n from a power law distribution. """ return [seed.paretovariate(exponent - 1) for i in range(n)] @py_random_state(2) def zipf_rv(alpha, xmin=1, seed=None): r"""Returns a random value chosen from the Zipf distribution. The return value is an integer drawn from the probability distribution .. math:: p(x)=\frac{x^{-\alpha}}{\zeta(\alpha, x_{\min})}, where $\zeta(\alpha, x_{\min})$ is the Hurwitz zeta function. Parameters ---------- alpha : float Exponent value of the distribution xmin : int Minimum value seed : integer, random_state, or None (default) Indicator of random number generation state. See :ref:`Randomness<randomness>`. Returns ------- x : int Random value from Zipf distribution Raises ------ ValueError: If xmin < 1 or If alpha <= 1 Notes ----- The rejection algorithm generates random values for a the power-law distribution in uniformly bounded expected time dependent on parameters. See [1]_ for details on its operation. Examples -------- >>> nx.zipf_rv(alpha=2, xmin=3, seed=42) # doctest: +SKIP References ---------- .. [1] Luc Devroye, Non-Uniform Random Variate Generation, Springer-Verlag, New York, 1986. """ if xmin < 1: raise ValueError("xmin < 1") if alpha <= 1: raise ValueError("a <= 1.0") a1 = alpha - 1.0 b = 2**a1 while True: u = 1.0 - seed.random() # u in (0,1] v = seed.random() # v in [0,1) x = int(xmin * u**-(1.0 / a1)) t = (1.0 + (1.0 / x))**a1 if v * x * (t - 1.0) / (b - 1.0) <= t / b: break return x def cumulative_distribution(distribution): """Returns normalized cumulative distribution from discrete distribution.""" cdf = [0.0] psum = float(sum(distribution)) for i in range(0, len(distribution)): cdf.append(cdf[i] + distribution[i] / psum) return cdf @py_random_state(3) def discrete_sequence(n, distribution=None, cdistribution=None, seed=None): """ Return sample sequence of length n from a given discrete distribution or discrete cumulative distribution. One of the following must be specified. distribution = histogram of values, will be normalized cdistribution = normalized discrete cumulative distribution """ import bisect if cdistribution is not None: cdf = cdistribution elif distribution is not None: cdf = cumulative_distribution(distribution) else: raise nx.NetworkXError( "discrete_sequence: distribution or cdistribution missing") # get a uniform random number inputseq = [seed.random() for i in range(n)] # choose from CDF seq = [bisect.bisect_left(cdf, s) - 1 for s in inputseq] return seq @py_random_state(2) def random_weighted_sample(mapping, k, seed=None): """Returns k items without replacement from a weighted sample. The input is a dictionary of items with weights as values. """ if k > len(mapping): raise ValueError("sample larger than population") sample = set() while len(sample) < k: sample.add(weighted_choice(mapping, seed)) return list(sample) @py_random_state(1) def weighted_choice(mapping, seed=None): """Returns a single element from a weighted sample. The input is a dictionary of items with weights as values. """ # use roulette method rnd = seed.random() * sum(mapping.values()) for k, w in mapping.items(): rnd -= w if rnd < 0: return k
Close