Skip to content

Commit

Permalink
SimSystem and SimTools update
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Herzog committed Oct 4, 2024
1 parent 15b8cd3 commit ca306ea
Show file tree
Hide file tree
Showing 196 changed files with 7,304 additions and 2,234 deletions.
1 change: 0 additions & 1 deletion SimSystem/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java">
Expand Down
20 changes: 10 additions & 10 deletions SimSystem/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.45.2.0</version>
<version>3.46.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 -->
<dependency>
Expand All @@ -39,13 +39,13 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.15.1</version>
<version>2.16.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.5</version>
<version>5.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
Expand All @@ -63,42 +63,42 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.21.1</version>
<version>2.23.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.2</version>
<version>5.11.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.2</version>
<version>5.11.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<!--
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.12</version>
<version>2.0.16</version>
<scope>test</scope>
</dependency>
-->
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.12</version>
<version>2.0.16</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-nop -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>2.0.12</version>
<version>2.0.16</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.odftoolkit/simple-odf -->
<dependency>
Expand All @@ -123,7 +123,7 @@
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-core</artifactId>
<version>4.10.0</version>
<version>5.1.0</version>
</dependency>
</dependencies>

Expand Down
15 changes: 12 additions & 3 deletions SimSystem/src/main/java/mathtools/NumberTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* Enthält einige statische Routinen zur Umwandlung von Zeichenketten in Zahlen
* und umgekehrt.
* @author Alexander Herzog
* @version 2.7
* @version 2.8
*/
public final class NumberTools {
/** String, der "0" enthält (um diesen nicht mehrfach anlegen zu müssen) */
Expand Down Expand Up @@ -1214,17 +1214,26 @@ public static Double getDouble(final String s) {

boolean isPlain=true;
boolean hasDecimal=false;
boolean needDecialReplace=false;
final int len=s.length();
for (int i=0;i<len;i++) {
final char c=s.charAt(i);
if (c>='0' && c<='9') continue;
if (c=='-' && i>0) {isPlain=false; break;}
if ((c=='.' || c==',') && !hasDecimal) hasDecimal=true; else {isPlain=false; break;}
if ((c=='.' || c==',') && !hasDecimal) {
hasDecimal=true;
if (c==',') needDecialReplace=true;
}
else {isPlain=false; break;}
}
if (isPlain) {
if (hasDecimal) {
try {
return fastBoxedValue(Double.parseDouble(s));
if (needDecialReplace) {
return fastBoxedValue(Double.parseDouble(s.replace(',','.')));
} else {
return fastBoxedValue(Double.parseDouble(s));
}
} catch (NumberFormatException e) {/* bei zu großen Zahlen: Fallback auf Double-Parser, der kommt damit klar */}
} else {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/**
* Copyright 2024 Alexander Herzog
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package mathtools.distribution;

import java.io.Serializable;

import org.apache.commons.math3.distribution.AbstractRealDistribution;
import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.random.RandomGenerator;

/**
* Klasse zur Abbildung der Arcus Sinus-Verteilung<br>
* Siehe auch: <a href="http://www.randomservices.org/random/special/Arcsine.html">http://www.randomservices.org/random/special/Arcsine.html</a>
* @author Alexander Herzog
*/
public class ArcsineDistribution extends AbstractRealDistribution implements Cloneable, Serializable, DistributionWithRandom {
/**
* Serialisierungs-ID der Klasse
* @see Serializable
*/
private static final long serialVersionUID=6569135516191696579L;

/**
* Untere Grenze des Trägers
*/
public final double a;

/**
* Obere Grenze des Trägers
*/
public final double b;

/**
* Konstruktor
* @param a Untere Grenze des Trägers
* @param b Obere Grenze des Trägers
*/
public ArcsineDistribution(final double a, final double b) {
super(null);
this.a=a;
this.b=Math.max(a+0.0001,b);
}

/**
* Copy-Konstruktor
* @param source Zu kopierende Ausgangsverteilung
*/
public ArcsineDistribution(final ArcsineDistribution source) {
this((source==null)?0:source.a,(source==null)?10:source.b);
}

@Override
public double density(double x) {
if (x<=a || x>=b) return 0;
x=(x-a)/(b-a);
return 1.0/Math.PI/Math.sqrt(x*(1-x));
}

@Override
public double cumulativeProbability(double x) {
if (x<=a) return 0;
if (x>=b) return 1;
x=(x-a)/(b-a);

return 2.0/Math.PI*Math.asin(Math.sqrt(x));
}

@Override
public ArcsineDistribution clone() {
return new ArcsineDistribution(a,b);
}

@Override
public double getNumericalMean() {
return (a+b)/2.0;
}

@Override
public double getNumericalVariance() {
return 1.0/8.0*(b-a)*(b-a);
}

@Override
public double getSupportLowerBound() {
return a;
}

@Override
public double getSupportUpperBound() {
return b;
}

@Override
public boolean isSupportLowerBoundInclusive() {
return true;
}

@Override
public boolean isSupportUpperBoundInclusive() {
return true;
}

@Override
public boolean isSupportConnected() {
return true;
}

@Override
public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
if (p<0.0 || p>1.0) throw new OutOfRangeException(p,0,1);

if (p==0.0) return getSupportLowerBound();
if (p==1.0) return getSupportUpperBound();

/* p=2/pi*arcsin(sqrt(x)) <=> x=(sin(pi/2*p))^2 */
final double z=Math.pow(Math.sin(Math.PI/2.0*p),2);
return z*(b-a)+a;
}

@Override
public double random(final RandomGenerator generator) {
return inverseCumulativeProbability(generator.nextDouble());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ public double inverseCumulativeProbabilityWithOutThrowsAndChecks(double p) {
*/
@Override
public double random(final RandomGenerator generator) {
/* return inverseCumulativeProbabilityWithOutThrowsAndChecks(rnd.nextDouble()); */
/* return inverseCumulativeProbabilityWithOutThrowsAndChecks(generator.nextDouble()); */

double p=generator.nextDouble();

Expand Down Expand Up @@ -1057,7 +1057,7 @@ public double getMean() {
double scale=1/argumentScaleFactor;
for (int i=0;i<densityData.length;i++) {
densitySum+=densityData[i];
sum+=densityData[i]*(scale*i);
sum+=densityData[i]*(scale*(i+0.5));
}
if (densitySum==0.0) return 0.0;
sum/=densitySum;
Expand Down Expand Up @@ -1114,7 +1114,7 @@ private double getXSqr() {
double scale=1/argumentScaleFactor;
for (int i=0;i<densityData.length;i++) {
densitySum+=densityData[i];
sum+=densityData[i]*(scale*i)*(scale*i);
sum+=densityData[i]*(scale*(i+0.5))*(scale*(i+0.5));
}
if (densitySum==0.0) return 0.0;
sum/=densitySum;
Expand All @@ -1133,7 +1133,7 @@ private double getXPow3() {
double scale=1/argumentScaleFactor;
for (int i=0;i<densityData.length;i++) {
densitySum+=densityData[i];
sum+=densityData[i]*(scale*i)*(scale*i)*(scale*i);
sum+=densityData[i]*(scale*(i+0.5))*(scale*(i+0.5))*(scale*(i+0.5));
}
if (densitySum==0.0) return 0.0;
sum/=densitySum;
Expand Down
Loading

0 comments on commit ca306ea

Please sign in to comment.