我需要运行一个python脚本一段随机的时间,暂停它,得到一个堆栈回溯,并取消它.我已经用Google搜索了一些方法来做到这一点,但我认为没有明显的解决方案.
扩展streetparade的问题,我想问一下随机算法和启发式算法之间有什么区别(如果有的话).
说随机算法实际上是一种启发式算法是正确的吗?
我是Python的新手,但对于大学的论文,我需要应用一些模型,最好使用Python.我花了几天时间使用我附带的代码,但是我无法提供帮助,这有什么不对,它不是创建一个随机过程,看起来像标准的布朗运动有漂移.我的参数如mu和sigma(预期回报或漂移和波动)往往只会改变噪声过程的斜率.这是我的问题,它看起来像噪音.希望我的问题足够具体,这是我的coode:
import math
from matplotlib.pyplot import *
from numpy import *
from numpy.random import standard_normal
'''
geometric brownian motion with drift!
Spezifikationen:
mu=drift factor [Annahme von Risikoneutralitaet]
sigma: volatility in %
T: time span
dt: lenght of steps
S0: Stock Price in t=0
W: Brownian Motion with Drift N[0,1]
'''
T=1
mu=0.025
sigma=0.1
S0=20
dt=0.01
Steps=round(T/dt)
t=(arange(0, Steps))
x=arange(0, Steps)
W=(standard_normal(size=Steps)+mu*t)### standard brownian motion###
X=(mu-0.5*sigma**2)*dt+(sigma*sqrt(dt)*W) ###geometric brownian motion####
y=S0*math.e**(X)
plot(t,y)
show()
Run Code Online (Sandbox Code Playgroud) 我正在实现一个小的遗传算法框架 - 主要是供私人使用,除非我设法做出合理的事情,我将把它作为开源发布.现在我专注于选择技术.到目前为止,我已经实施了轮盘赌选择,随机通用抽样和锦标赛选择.我的列表中的下一个是基于排名的选择.与我已经实现的其他技术相比,我在查找相关信息方面遇到了一些困难,但到目前为止,这是我的理解.
如果你的人口中有你想让下一轮的合理父母,你首先要通过它,并将每个人的适应度除以人口中的总体适应度.
然后你使用其他一些选择技术(如轮盘赌轮)来实际确定选择谁进行繁殖.
它是否正确?如果是这样,我是否正确地认为排名调整是一种预处理步骤,然后必须采用实际选择程序来挑选候选人?如果我误解了这一点,请纠正我.我很感激任何额外的指示.
roulette-wheel-selection selection stochastic genetic-algorithm
我在R中使用梯度下降有一个多变量线性回归的工作实现.我想看看我是否可以使用我所拥有的随机梯度下降.我不确定这是否真的效率低下.例如,对于α的每个值,我想要执行500次SGD迭代并且能够指定每次迭代中随机挑选的样本的数量.这样做会很好,所以我可以看到样本数量如何影响结果.我在使用迷你批处理时遇到了麻烦,我希望能够轻松地绘制结果.
这是我到目前为止:
# Read and process the datasets
# download the files from GitHub
download.file("https://raw.githubusercontent.com/dbouquin/IS_605/master/sgd_ex_data/ex3x.dat", "ex3x.dat", method="curl")
x <- read.table('ex3x.dat')
# we can standardize the x vaules using scale()
x <- scale(x)
download.file("https://raw.githubusercontent.com/dbouquin/IS_605/master/sgd_ex_data/ex3y.dat", "ex3y.dat", method="curl")
y <- read.table('ex3y.dat')
# combine the datasets
data3 <- cbind(x,y)
colnames(data3) <- c("area_sqft", "bedrooms","price")
str(data3)
head(data3)
################ Regular Gradient Descent
# http://www.r-bloggers.com/linear-regression-by-gradient-descent/
# vector populated with 1s for the intercept coefficient
x1 <- rep(1, length(data3$area_sqft))
# appends to dfs
# create x-matrix of independent variables …Run Code Online (Sandbox Code Playgroud) HY,
我正在寻找一个提供金融随机技术分析实施的API /库.
有人知道现成的解决方案吗?
谢谢,
我有一个随机微分方程系统,我想解决.我希望这个问题已经解决了.我有点担心构造我自己的求解器,因为我担心我的解算器会太慢,并且可能存在数值稳定性的问题.
是否存在针对此类问题的python模块?
如果没有,是否有解决此类系统的标准方法.
我正在编写java代码来解决模拟退火方法的问题.我需要一种true只用概率exp(a/b)生成随机的方法,其中a和b给定参数.
谢谢.
我对整个R-thing仍然很陌生.
我有以下目标; 我有一个正弦函数描述了钙粒子数随时间的变化:类似于y = a*sin(b*t)+ c
实际上,在随机事件中描述了钙的产生和去除,我想在我的函数中添加一个随机噪声项(最好是平均噪声幅度可扩展).
比如z = y + random*Amplitude
你能帮我吗?
最好
这个问题在参考时是对代码 - 高尔夫挑战的观察.
提交的R解决方案是一个有效的解决方案,但是我们中的一些人(可能只是我)似乎对为什么需要进行初始X=m重新分配感到茫然.
代码由@Giuseppe高调一点,所以我会给读者写一些评论.
function(m){
X=m
# Re-assign input m as X
while(any(X-(X=X%*%m))) 0
# Instead of doing the meat of the calculation in the code block after `while`
# OP exploited its infinite looping properties to perform the
# calculations within the condition check.
# `-` here is an abuse of inequality check and relies on `any` to coerce
# the numeric to logical. See `as.logical(.Machine$double.xmin)`
# The code basically multiplies the matrix …Run Code Online (Sandbox Code Playgroud) floating-point r matrix-multiplication stochastic-process stochastic
stochastic ×10
python ×3
r ×3
finance ×2
java ×2
algorithm ×1
heuristics ×1
integrator ×1
noise ×1
profile ×1
random-walk ×1
selection ×1
trigonometry ×1