我对matplotlib hist函数感到困惑.
文档说明:
如果是一系列值,则使用二进制数的下限值.
但是当我按顺序有两个值,即[0,1]时,我只得到1个bin.当我有三个这样的时候:
plt.hist(votes, bins=[0,1,2], normed=True)
Run Code Online (Sandbox Code Playgroud)
我只买了两个箱子.我的猜测是最后一个值只是最后一个bin的上限.
有没有办法在最后一个bin中包含值的"其余",除了那个非常大的值?(换句话说,没有让那个箱子比其他箱子大得多)
似乎最后一个bin值包含在最后一个bin中
votes = [0,0,1,2]
plt.hist(votes, bins=[0,1])
Run Code Online (Sandbox Code Playgroud)
这给了我一个高度为3的箱子,即0,0,1.而:
votes = [0,0,1,2]
plt.hist(votes, bins=[0,1,2])
Run Code Online (Sandbox Code Playgroud)
给我两个箱子,每箱两个.我发现这个反作用是直观的,添加一个新的bin会改变其他bin的宽度限制.
votes = [0,0,1]
plit.hist[votes, bins=2)
Run Code Online (Sandbox Code Playgroud)
yeilds两个大小为2和1的区域.由于x轴从0变为1,因此这些区域似乎已经被分割为0,5.
如何解释bin数组?数据是如何分开的?
我用scala(2.9.2)连接到postgres数据库.
我第一次做一个SELECT(通过在IntelliJ中的sbt终端运行'run'代码)它运行良好,但是如果我在sbt shell中再次"运行",我会收到一个错误声明:
[error] (run-main) java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost/db
java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost/db
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at SequenceGenerator$.connect(Validator.scala:50)
at SequenceGenerator$.generate(Validator.scala:54)
at Main$.main(Validator.scala:32)
at Main.main(Validator.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
Run Code Online (Sandbox Code Playgroud)
我在build.sbt文件中通过sbt安装了postgres连接器.
libraryDependencies += "postgresql" % "postgresql" % "9.1-901.jdbc4"
Run Code Online (Sandbox Code Playgroud)
这是我制作SELECT的代码:
object SequenceGenerator{
def connect() = {
DriverManager.getConnection("jdbc:postgresql://localhost/db","user", "pass")
}
def generate() = {
val db = connect()
val st = db.createStatement
val res = st.executeQuery("SELECT value from table LIMIT 2")
while( …Run Code Online (Sandbox Code Playgroud)