嗨蟒蛇爱好者!
我目前正在研究用于研究目的的信号过滤,并决定使用SciPy.没什么特别的,只是日常工作的自动化.
所以,这是代码
from scipy.signal import medfilt
print(medfilt([2,6,5,4,0,3,5,7,9,2,0,1], 5))
Run Code Online (Sandbox Code Playgroud)
但问题是返回的序列计算错误
SciPy: [ 2. 4. 4. 4. 4. 4. 5. 5. 5. 2. 1. 0.]
Me : [ 5. 4.5 4. 4. 4. 4. 5. 5. 5. 2. 1.5 1.]
Run Code Online (Sandbox Code Playgroud)
似乎是,包的开发人员搞砸了一个细节.当孔径(SciPy中的内核)大于要分析的窗口时,还有另一个过滤规则.
例如,kernel=5过滤子序列的[2, 6, 5]中位数为5而不是2,因为SciPy计算的不是吗?同样地,如果kernel=5对于子序列[2,6,5,4]中位数是5和4,我们需要取它们之间的平均值,因此,中位数是4.5.
有人可以解释一下我在这种情况下得到了正确的结果吗?
我正在尝试在 Spring Boot 应用程序中使用 testcontainers 和 Flyway 设置测试环境。所有这一切都应该通过 DinD 方案运行。
目前测试示例如下:
import com.testapp.testapp.entity.TestEntity
import com.testapp.testapp.service.TestService
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.annotation.Import
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
import org.testcontainers.containers.PostgreSQLContainer
import org.testcontainers.spock.Testcontainers
import spock.lang.Shared
import spock.lang.Specification
@Testcontainers
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringBootTest
@Import([FlywayAutoConfiguration.class])
class ApplicationTests extends Specification {
@Shared
PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer()
.withDatabaseName("testdb")
.withUsername("postgres")
.withPassword("12345")
@Autowired
public TestService testappService;
@Test
def "entity_created"(){
given: "init test entity"
UUID uuid = UUID.randomUUID();
when: "create test entity"
def testEntity = …Run Code Online (Sandbox Code Playgroud) 我已经研究过函数逼近方法scipy.optimize,在读取函数的描述之后(可能是错误的)它们只是近似非线性函数.
例如,如果我在zip()for x和函数之后对输出进行采样y
[(1,1),(4,2),(6,4),(8,6),(10,11)]
Run Code Online (Sandbox Code Playgroud)
如您所见,非线性函数近似得更好,但我需要线性用于我的目的.
我承认错过了函数文档中遗漏的可能性,所以如果问题可以用"阅读文档"方式回答,我表示歉意.