小编Alo*_*uez的帖子

估计Java中的Holt-Winters平滑系数

我正在研究一个用Java编写的系统,它能够使用历史数据执行预测.使用的算法是这个Holt-Winters实现的Java端口(乘法季节性).

我有几个时间序列我们想要分析,我们需要不同的时间序列平滑系数.该算法似乎在一瞬间工作真的很好,唯一的问题是,如何确定平滑系数(α,β,γ)是最明智的值.

我知道我需要某种非线性优化,但我根本不是数学家,所以我在所有这些理论和概念中都有点迷失.

编辑:

我有很多不同的时间序列要分析,我想知道是否有一个标准/足够好的技术(库会更好)来计算我应该给Holt-Winters算法的平滑参数.

java statistics time-series

6
推荐指数
1
解决办法
4194
查看次数

Java示例包含封装,多态和继承?

我需要使用Java生成一个具有所列出的面向对象编程特性的项目.

有人可以查看我的快速示例程序,以确认我了解这些特性是如何实现的,并且它们都是正确存在和完成的吗?

package Example;

public class Parent {

    private int a;
    public void setVal(int x){
        a = x;
    }
    public void getVal(){
        System.out.println("value is "+a);
    }
}

public class Child extends Parent{

    //private fields indicate encapsulation
    private int b;
    //Child inherits int a and getVal/setVal methods from Parent
    public void setVal2(int y){
        b = y;
    }
    public void getVal2(){
        System.out.println("value 2 is "+b);
    }
    //having a method with the same name doing different things
    //for different parameter types indicates overloading, …
Run Code Online (Sandbox Code Playgroud)

java polymorphism inheritance encapsulation

6
推荐指数
1
解决办法
1万
查看次数

Maven + Spring +动态Web模块(Eclipse)= java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderListener

我的问题是,甚至设置"部署程序集"以包含maven依赖项,这使得我的类没有找到,我不知道还能做什么.

我只是注意到这个ContextLoaderListener类,因为其他类似乎包含在我的包中.

我的文件是pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mkyong.common</groupId>
    <artifactId>SpringMVC</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>SpringMVC Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <!-- <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> 
            <version>3.8.1</version> <scope>test</scope> </dependency> -->

        <!-- Spring framework -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>2.5.6</version>
        </dependency>

        <!-- Spring MVC framework -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>2.5.6</version>
        </dependency>

        <!-- JSTL -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.1.2</version>
        </dependency>

        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>

        <!-- for compile only, your container should have this -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

    <build>
        <finalName>SpringMVC</finalName>
        <plugins> …
Run Code Online (Sandbox Code Playgroud)

eclipse spring maven

5
推荐指数
1
解决办法
1万
查看次数

我们在哪里可以使用ArrayList <?扩展My_Class>

我们可以在哪里,ArrayList<? extends My_Class>因为如果您以这种方式声明它,它将不允许您添加任何新元素:

ArrayList<? extends My_Class> obj=new ArrayList<? extends My_Class>();
list.add(new Derived_My_Class()); //this is compilation error
Run Code Online (Sandbox Code Playgroud)

java generics

5
推荐指数
1
解决办法
1252
查看次数

云平台:我可以在任何IaaS中安装像Ghostscript这样的开源软件吗?

在我的应用程序中,我必须在服务器中安装Ghostscript来运行应用程序.它是Google Compute Engine(IaaS),Amazon EC2,VMware,WindowsAzure等,或任何人都支持用户端的软件安装.

cloud amazon cloud-hosting iaas

5
推荐指数
1
解决办法
369
查看次数

IntelliJ IDEA:如何为内部类启用导入

当我在IDEA 12中粘贴带有内部实体(类或枚举)名称的代码片段时,我得到一个对话框,用于导入该实体的包.如果我正在处理类和实体在同一个包中,IDEA只是在实体名称之前写出外部类名和一个点.与文件启动时导入部分中导入实体相比,这种情况要糟糕得多.如何禁用这种行为并强制IDEA在导入部分专门导入所有内容?

intellij-idea

5
推荐指数
1
解决办法
3325
查看次数

用于从锚标记中提取锚文本的Javascript

需要以下方面的帮助。

在javascript中,需要传递一个输入

例如:

str="<a href=www.google.com>Google</a>"; // this is for example actual input vary
// str is passed as parameter for javascript function
Run Code Online (Sandbox Code Playgroud)

输出应检索为“Google”。

我在java中有正则表达式,它在其中运行良好。

String regex = "< a [ ^ > ] * > ( . * ? ) < / a > ";
Pattern p = Pattern.compile(regex, Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
Run Code Online (Sandbox Code Playgroud)

但在 javascript 中它不起作用。

我怎样才能在 JavaScript 中做到这一点。任何人都可以为我提供有关 javascript 实现的帮助吗?

javascript java regex

4
推荐指数
1
解决办法
8311
查看次数

Hibernate级联删除孤儿

我有2个实体:新闻和新闻评论

@Entity
@Table(name = "news", schema = "city")
public class News {

        private Set<CommentNews> comments = new HashSet<CommentNews>();
        ...
    @OneToMany(cascade={javax.persistence.CascadeType.ALL})
    @Cascade(CascadeType.DELETE_ORPHAN)
    @JoinColumn(name="news_id")
    public Set<CommentNews> getComments() {
        return comments;
    }
}
Run Code Online (Sandbox Code Playgroud)

@Entity
@Table(name = "comment_news", schema = "city")
public class CommentNews {
private News news;            
    ...

    @ManyToOne
@Cascade(CascadeType.DELETE_ORPHAN)
@JoinColumn(name = "news_id")
public News getNews() {
    return news;
}
}
Run Code Online (Sandbox Code Playgroud)

和这样的代码:

public void delete(int id) {
        T obj = null;
        session = HibernateUtil.openSession();
        try {
            session.beginTransaction();
            obj = (T) session.get(persistentClass, id); …
Run Code Online (Sandbox Code Playgroud)

hibernate cascading-deletes all-delete-orphan

2
推荐指数
1
解决办法
8524
查看次数

F-bounded类型和方法,在参数和返回站点具有类型参数

我有一个F-bounded类型,我的目标是创建一个类型参数化方法,以便能够重用它.这是示例代码:

trait FType {
  type ThisType <: FType

  def deepCopy(): ThisType

}

class ConcreteType extends FType {

  override type ThisType = ConcreteType

  override def deepCopy(): ConcreteType = this

}

class ConcreteType2 extends FType {

  override type ThisType = ConcreteType2

  override def deepCopy(): ConcreteType2 = this

}

object FType {

  def deepCopy[T <: FType](_type: T): T = {
    _type.deepCopy()
  }

/*  def deepCopy2(c: ConcreteType2): ConcreteType2 = {
    c.deepCopy()
  }*/

  def main(args: Array[String]): Unit = {
    //deepCopy2(new ConcreteType2)
  }

}
Run Code Online (Sandbox Code Playgroud)

但是,代码无法编译.编译器抛出此错误:

Error:(29, …
Run Code Online (Sandbox Code Playgroud)

scala path-dependent-type f-bounded-polymorphism

2
推荐指数
1
解决办法
72
查看次数

如何解决此slf4j异常,找不到日志方法

我正在遵循SLF4J异常,我试图从pom.xml中删除slf4j依赖关系,但它仍然存在,有人可以帮忙吗?

抛出的异常为:。。

 " org.osgi.framework.BundleException: Exception in
 oracle.acs.assessment.PatchDataExtractionActivator.start() of bundle
 oracle.acs.mf.PatchDataExtractionBundle.
         at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:1018)
>         at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:974)
>         at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:346)
>         at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:260)
>         at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:252)
>         at org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start(FrameworkCommandProvider.java:260)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:606)
>         at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute(FrameworkCommandInterpreter.java:150)
>         at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(FrameworkConsole.java:291)
>         at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(FrameworkConsole.java:276)
>         at com.sun.svc.container.admin.cli.Console.run(Console.java:85)
>         at java.lang.Thread.run(Thread.java:724) Caused by: java.lang.NoSuchMethodError:
> org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
>         at org.apache.log4j.Category.log(Category.java:288)
>         at org.apache.commons.logging.impl.Log4JLogger.info(Log4JLogger.java:199)
>         at org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:412)
>         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:350)
>         at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
>         at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
>         at …
Run Code Online (Sandbox Code Playgroud)

spring slf4j java-ee maven

0
推荐指数
1
解决办法
1万
查看次数

意外类型平均值

由于某种原因,命令提示符继续询问我输入,但我在第12行(sum + one)= sum 上放置一个值.如果你们可以帮我确定什么是错误的,这将是惊人的.

import java.util.Scanner;

public class FunnyAverage {
   public static void main(String[] args){          
   Scanner in = new Scanner(System.in);
   System.out.print("How many values to read? ");
   int top = in.nextInt();
   System.out.print("Enter Value: ");
   int one = in.nextInt();
   int number = 0;
   int sum = 0;
   (sum + one) = sum;

   while (number>top){
       while (one % 6 != 0&&one % 17 != 0) {
           System.out.print("Enter Value: ");
           one = in.nextInt(); 
           number++;
       }
   }

   if (sum/top != 0){
       System.out.print("Average: …
Run Code Online (Sandbox Code Playgroud)

java

-4
推荐指数
1
解决办法
170
查看次数