Statistical analysis in java

Application for Statistical Analysis using Java Programming Language

My requirement is to obtain data regarding Java EE code, though any code analyzer can be utilized. To be precise, it operates on Java byte code and generates statistics on different aspects such as cyclomatic complexity, mutable global state, and more.

(Java) Statistics program

My goal is to develop a software that performs the subsequent actions.

The program first requests an integer value from the user, which is then stored. It then utilizes the user’s input to determine the Arithmetic Mean, Geometric Mean, as well as the minimum and maximum values of the number entered by the user.

The majority of the task has been completed and as per my observation, in the initial method, the User was prompted to provide an input which was then saved as ‘userInput’ in a variable.

I am uncertain about utilizing userInput for calculating Arithmetic Mean, Geometric Mean, as well as determining the minimum and maximum values.

public class SimpleStatistics < public static double[] getUserInput() < // Returns a string of doubles Scanner sc = new Scanner(System.in); // Create list ListinputList = new ArrayList(); // Getting input System.out.println("Please enter number"); double userInput = sc.nextDouble(); // See our new list System.out.println(inputList); double arr[] = new double[inputList.size()]; System.out.println(inputList.size()); return arr; > public static double arithmeticMean(double[] nums) < double mean = 0; double sum = 0; for (int i = 0; i < nums.length; i++) < sum = sum + nums[i]; >mean = sum / nums.length; return mean; > public static double geometricMean(double[] nums) < double gm = 1.0; for (int i = 0; i < nums.length; i++) < gm *= nums[i]; >gm = Math.pow(gm, 1.0 / (double) nums.length); return gm; > public static double[] minAndmax(double[] nums) < double min = nums[0]; double max = nums[0]; for (int i = 1; i < nums.length; i++) < if (nums[i] < min) < min = nums[i]; >else if (nums[i] > max) < max = nums[i]; >else < >> double[] minAndmax = < min, max >; return minAndmax; > public static double[] scaleUp(double[] nums, int factor) < for (int i = 0; i < nums.length; i++) < nums[i] *= factor; >return nums; > public static double[] scaleDown(double[] nums, int factor) < for (int i = 0; i < nums.length; i++) < nums[i] /= factor; >return nums; > public static void main(String[] args) < Scanner sc = new Scanner(System.in); double[] input = < 1, 2.8, 5.3, 100, -5, -6.5 >; System.out.println("Choose a option 1-6"); boolean exit = false; while (!exit) < System.out.println(); System.out .println("1) Arithmetic mean, 2) Geometric mean, 3) minAndmax, 4) Scale Up, 5) Scale Down, 6) Quit"); System.out.print("Input ->"); int choice = sc.nextInt(); System.out.println(); switch (choice) < case 1: < // Arithmetic mean System.out.println("Arithmetic mean"); System.out.println(arithmeticMean(input)); break; >case 2: < // Geometric mean System.out.println("Geometric mean"); System.out.println(arithmeticMean(input)); break; >case 3: < // Min and max System.out.println("Min and Max"); for (double i : minAndmax(input)) < System.out.print(i + ", "); >break; > case 4: < // Scale Up System.out.println("Scale Up"); System.out .print("Please enter factor by which you want to scale ->"); int factor = sc.nextInt(); for (double i : scaleUp(input, factor)) < System.out.print(i + ", "); >break; > case 5: < // Scale Down System.out.println("Scale Down"); System.out .print("Please enter factor by which you want to scale ->"); int factor = sc.nextInt(); for (double i : scaleDown(input, factor)) < System.out.print(i + ", "); >break; > case 6: < exit = true; break; >> > > > 

Instead of adding your number to double array. Change , modify your getUserInput() function as follows:

public static double[] getUserInput() < Scanner sc = new Scanner(System.in); System.out.println("How many numbers are you entering?"); double[] arr = new double[sc.nextInt()]; for (int i = 0; i < arr.length; i++) < System.out.println("Please enter your number"); arr[i] = sc.nextDouble(); >sc.close(); return arr; > 

Revise the approach for getUserInput as follows:

public static double[] getUserInput() < Scanner sc = new Scanner(System.in); ListinputList = new ArrayList(); System.out.println("Please enter how many numbers you will be inputing"); int numberOfInputs = sc.nextInt(); for (int i = 0; i < numberOfInputs; i++) < System.out.println("Please enter a number"); double userInput = sc.nextDouble(); inputList.add(userInput); >sc.close(); double[] arr = new double[inputList.size()]; for (int i = 0; i < arr.length; i++) < arr[i] = inputList.get(i); >return arr; > 

In your main method, utilize the input by invoking the method, for instance.

// Arithmetic mean System.out.println("Arithmetic mean"); System.out.println(arithmeticMean(getUserInput())); break; 

If you need any further assistance, please don’t hesitate to ask. I’m glad to be of help.

Machine Learning Statistics, Inferential Statistics. Inferential statistics are methods for quantifying properties of a population from a small Sample:. You take data from a sample and make a prediction about the whole population. For example, you can stand in a shop and ask a sample of 100 people if they like chocolate.. From your research, using …

Читайте также:  Java consumer with return

Statistical calculations

Are there any pre-existing Java libraries available for computing the median?

While using apache.commons.math for various statistical computations, I could not locate the median function.

Compile the numbers into a list, arrange the list in ascending order, and retrieve the median value (or the mean of the two middle values if the count is even). There is no need for any computations.

Do you know which version of Apache Commons Math you have installed? The version that includes median class is 2.1 and newer, although I cannot confirm if it is available in older versions. You can utilize it by following this format:

Median median = new Median(); median.evaluate(values); 

Assuming the list of integers is named «values», insert them into a List object container.

List values; . populate values . Collections.sort(values); int median; int midpoint=values.size()/2; if (values.size()%2==1) median=values.get(midpoint+1).intValue(); else median=(values.get(midpoint).intValue()+values.get(midpoint+1).intValue())/2; 

When dealing with a significant amount of values, such as hundreds or more, manipulating the mod-2 may be deemed unnecessary despite its technical accuracy.

It’s possible that there is a faster approach to accomplish this task, as sorting can be time-consuming for extensive lists. Nonetheless, the current method is effective.

Don’t forget to verify if there is a list with no elements. It’s possible that I overlooked some other edge cases.

Java — Swing / Java2D statistics and visualisation libraries, Swing / Java2D statistics and visualisation libraries. I’m looking for a multifaceted Java2D / Swing visualisation library with which I can render different statistics. Specifically, I’m looking for timeline plotting (with a configurable scrolling and compressing timeline and the ability to chart events at certain points along …

Getting code statistics from big projects

I’m looking for tools that can provide code statistics, preferably for Java EE code. Do you have any recommendations or suggestions on existing code analyzers that I could use instead of creating my own?

This refers to the location, quantity of courses, and available libraries.

In accordance with jitter’s explanation, Sonar is the ideal solution you require. It’s worth noting that while the tool previously utilized JavaNCSS, it now incorporates its own internal tool (referred to as SonarSquid) that flawlessly works with Java 1.5 or 1.6 projects since version 1.9.

Читайте также:  Lst это в питоне

Displayed above is an image with the alternative text, showcasing what appears to be a squid on the Sonar website that was created in May of 2009.

Furthermore, you have the ability to oversee an entire range of initiatives.

Gain a comprehensive understanding of the tool by accessing the Nemo demo instance.

Although the Metrics Eclipse Plugin is considered outdated nowadays, it still offers a variety of intriguing metrics that I have already utilized.

StateOfFlow is another tool that, although it offers fewer metrics, appears to be more up-to-date than the other option.

JavaNCSS, a tool that measures source code in Java, includes a few fundamental metrics such as NCSS, number of classes/packages/functions, and CCN.

Sonar is capable of backing up over 20 different code metrics, while Clover allows users to create custom metrics with a unique language.

In case the given information is insufficient, you may conduct a Google search using the keywords «java» and «metrics».

Testability Explorer is a tool that specializes in collecting specific statistics. It works with Java byte code and offers data on cyclomatic complexity, mutable global state, and other related metrics. This tool is available for free and is open-source, licensed under Apache 2.0.

Although the metrics of this niche project may not be as easy to relate to as LOC, it is still intriguing because it allows you to compare your projects with various well-known open-source projects, which could potentially make the results more valuable.

SLOCCount is a useful command line tool that provides statistics for various programming languages, including Java. I used it recently after JavaNCSS failed to run on a large codebase due to too many files. SLOCCount was able to run without any issues on IntelliJ IDEA’s extensive codebase. One of its convenient features is that it requires minimal configuration and automatically identifies and reports on different programming languages. I didn’t even need to specify *.java files for it to recognize them.

Using SLOCCount on Windows requires the use of Cygwin, which can be a drawback.

Java — Statistical calculations, The statistical median is nothing more than the middle value, so yes that should be fine. When there are an even number of values, however, you can’t just take the middle since there is no middle. Instead, you should take the average of the two values closest to the middle.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Java Statistical Analysis Tool, a Java library for Machine Learning

License

EdwardRaff/JSAT

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Читайте также:  Php fpm nginx php ini

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

…at are missing a leading zero.

Git stats

Files

Failed to load latest commit information.

README.md

Java Statistical Analysis Tool

JSAT is a library for quickly getting started with Machine Learning problems. It is developed in my free time, and made available for use under the GPL 3. Part of the library is for self education, as such — all code is self contained. JSAT has no external dependencies, and is pure Java. I also aim to make the library suitably fast for small to medium size problems. As such, much of the code supports parallel execution.

The current master branch of JSAT is going through a larger refactoring as JSAT moves to Java 8. This may cause some examples to break if used against the head version, but they should be fixible with minimal changes.

Ther current release of JSAT is version 0.0.9, and supports Java 6. The current master branch is now Java 8+.

You can download JSAT from maven central, add the below to your pom file

dependencies> dependency> groupId>com.edwardraffgroupId> artifactId>JSATartifactId> version>0.0.9version> dependency> dependencies>

If you want to use the bleeding edge, but don’t want to bother building yourself, I recommend you look at jitpack.io. It can build a POM repo for you for any specific commit version. Click on «Commits» in the link and then click «get it» for the commit version you want.

If you want to read the javadoc’s online, you can find them hosted on my website here.

For research and specialized needs, JSAT has one of the largest collections of algorithms available in any framework. See an incomplete list here.

Additional, there are unfortunately not as many ML tools for Java as there are for other languages. Compared to Weka, JSAT is usually faster.

If you want to use JSAT and the GPL is not something that will work for you, let me know and we can discuss the issue.

See the wiki for more information as well as some examples on how to use JSAT.

Updates to JSAT may be slowed as I begin a PhD program in Computer Science. The project isn’t abandoned! I just have limited free time, and will be balancing my PhD work with a full time job. If you discover more hours in the day, please let me know! Development will be further slowed due to some health issues. I’ll continue to try and be prompt on any bug reports and emails, but new features will be a bit slower. Please use the github issues first for contact.

If you use JSAT and find it helpful, citations are appreciated! Please cite the JSAT paper published at JMLR. If you’re feeling a little lazy, the bibtex is below:

@article, journal = , number = , pages = , title = , url = , volume = , year = > 

About

Java Statistical Analysis Tool, a Java library for Machine Learning

Источник

Оцените статью