python - 矩阵内的圆圈
问题描述
我正在尝试建立一个统计模型,该模型将检测与方差锥内的杆相互作用的可能性。
我已经设法在矩阵中创建了圆,但我想区分圆的内部和外部。有没有一种方法可以使圆函数之外的所有内容成为单独的值?
这是我到目前为止所拥有的:
import numpy as np
import matplotlib.pyplot as plt
def my_unit_circle(r):
d = 2*r + 1
rx, ry = d/2, d/2
x, y = np.indices((d, d))
return (np.abs(np.hypot(rx - x, ry - y)-r) < 0.5).astype(int)
model = my_unit_circle(300)
model[300:325,0:600] = 2
plt.matshow(model)
plt.show()'''
这给了我这个:
预先感谢您的任何帮助。
解决方案
推荐阅读
- testng - 无法在 Eclipse 中安装 testNG - 获取错误状态时找不到 URL 'https://dl.bintray.com/testng-team/testng-eclipse-release/'
- r - 为什么该图显示频率高于实际存在的频率?
- epson - 如何从 Zoho Sjeet 打印点阵
- visual-studio-code - 如何从解压目录安装正在本地开发的 vscode 扩展
- forms - Flutter:按下提交按钮后,如何使我的字段成为必填项并保存我的下拉列表和文本数据?
- string - 不能在 MIPS 中多次写入文件?
- javascript - 将字典输出到表:关键顺序问题
- vba - 尝试从现有 Word 邮件合并文档中提取邮寄地址
- python - 如何使用单词列表计算数据框中的字数?
- reactjs - 在 react 中直接使用 QuillJS 而不使用 react-quill