randpoints.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:atoolbox 作者: liweitianux 项目源码 文件源码
def generate(self, n=1):
        """
        Generate a sample of luminosity values within [min, max] from
        the above luminosity distribution.
        """
        results = []
        # Get the maximum value of the flux number density function,
        # which is a monotonically decreasing.
        M = self.fluxDensity(self.fmin)
        for i in range(n):
            while True:
                u = np.random.uniform() * M
                y = 10 ** np.random.uniform(low=np.log10(self.fmin),
                        high=np.log10(self.fmax))
                if u <= self.fluxDensity(y):
                    results.append(y)
                    break
        return results
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号