This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!pip install functools | |
from functools import partial | |
import numpy | |
from matplotlib import pyplot | |
# Define a PDF | |
x_samples = numpy.arange(-3, 3.01, 0.01) | |
PDF = numpy.empty(x_samples.shape) | |
PDF[x_samples < 0] = numpy.round(x_samples[x_samples < 0] + 3.5) / 3 | |
PDF[x_samples >= 0] = 0.5 * numpy.cos(numpy.pi * x_samples[x_samples >= 0]) + 0.5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""最小公倍数与最大公约数""" | |
def gcd(*numbers): | |
"""Return the greatest common divisor of the given integers""" | |
from fractions import gcd | |
return reduce(gcd, numbers) | |
def lcm(*numbers): | |
"""Return lowest common multiple.""" | |
def lcm(a, b): |
NewerOlder