我想使用nb-stepper {
counter-reset: stepper;
}
nb-stepper .step {
counter-increment: stepper;
}
nb-stepper .nb-checkmark::before {
content: counter(stepper) !important;
}
模块中的curve_fit
函数来确定正弦函数(和一个scipy.optimize
)的幅值,频率,相位。当我知道要使用的许多罪行时,这很容易做到。例如,当我从DFT(离散傅立叶变换)知道两个频率时:y0
和1.152
,我可以定义一个函数:
0.432
然后,使用def func(x, amp1, amp2, freq1 , freq2, phase1, phase2, y0):
return amp1*np.sin(freq1*x + phase1) + amp2*np.sin(freq2*x + phase2) + y0
和频率的约束间隔,我可以找到一个很好的拟合:
curve_fit
看起来很棒: css counters
但是在这种情况下,我已经准备好数据并且知道许多频率。您是否知道只定义一次param, _ = curve_fit(func, t, data, bounds=([-np.inf, -np.inf, 1.14, 0.43, -np.inf, -np.inf, -np.inf], [np.inf, np.inf, 1.16, 0.44, np.inf, np.inf, np.inf]))
并处理所有情况(例如五个正弦函数)?我试图将参数放入列表中,例如func
,我遍历了它们的长度。但是,为参数列表定义amp = [amp1, amp2, ... ]
存在问题。 bounds
对于确保现实模型非常重要。
解决方案不必基于bounds
。
答案 0 :(得分:1)
假设您事先知道频率,则问题很简单。您可以将下限设置为0,将上限设置为2 * pi *频率。对于安培,请设置任何数字(如果不需要边界,请设置为<?php
class Stud_controller extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->helper('url');
$this->load->database();
}
public function index() {
$query = $this->db->get("stud");
$data['records'] = $query->result();
$this->load->helper('url');
$this->load->view('Stud_view',$data);
}
public function add_student_view() {
$this->load->helper('form');
$this->load->view('Stud_add');
}
public function add_student() {
$this->load->model('Stud_Model');
$data = array(
'roll_no' => $this->input->post('roll_no'),
'name' => $this->input->post('name')
);
$this->Stud_Model->insert($data);
$query = $this->db->get("stud");
$data['records'] = $query->result();
$this->load->view('Stud_view',$data);
}
public function update_student_view() {
$this->load->helper('form');
$roll_no = $this->uri->segment('3');
$query = $this->db->get_where("stud",array("roll_no"=>$roll_no));
$data['records'] = $query->result();
$data['old_roll_no'] = $roll_no;
$this->load->view('Stud_edit',$data);
}
public function update_student(){
$this->load->model('Stud_Model');
$data = array(
'roll_no' => $this->input->post('roll_no'),
'name' => $this->input->post('name')
);
$old_roll_no = $this->input->post('old_roll_no');
$this->Stud_Model->update($data,$old_roll_no);
$query = $this->db->get("stud");
$data['records'] = $query->result();
$this->load->view('Stud_view',$data);
}
public function delete_student() {
$this->load->model('Stud_Model');
$roll_no = $this->uri->segment('3');
$this->Stud_Model->delete($roll_no);
$query = $this->db->get("stud");
$data['records'] = $query->result();
$this->load->view('Stud_view',$data);
}
}
?>
。
您可以以np.inf
的形式来表述函数,lambda x, amp1, phase1, amp2, phase2... : y
可以接受数量不确定的函数,只要您提供适当的初始猜测即可。
五个频率的示例代码:
curve_fit