MCPcopy
hub / github.com/shenweichen/GraphEmbedding / alias_sample

Function alias_sample

ge/alias.py:41–54  ·  view source on GitHub ↗

:param accept: :param alias: :return: sample index

(accept, alias)

Source from the content-addressed store, hash-verified

39
40
41def alias_sample(accept, alias):
42 """
43
44 :param accept:
45 :param alias:
46 :return: sample index
47 """
48 N = len(accept)
49 i = int(np.random.random() * N)
50 r = np.random.random()
51 if r < accept[i]:
52 return i
53 else:
54 return alias[i]

Callers 5

simulateFunction · 0.90
node2vec_walkMethod · 0.85
node2vec_walk2Method · 0.85
chooseNeighborFunction · 0.85
batch_iterMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected