C++ :: Statistics Code - Comparing Two Columns Of Numbers?

Aug 17, 2014

I am wondering if there is some repository of c++ code for statistics comparing two columns of numbers? Statistics are so common now that it seems like with the oo concept of reusable code there should be allot of that floating around. Code that would accept two vectors and generate comparisons like pearson's correlation, root mean square error, mean absolute error, median absolute error, etc would be very useful.

I have looked around some and find some code examples, and other posts basically saying, "Google the algorithm and figure it out yourself." At this point, there should almost be stl classes like the ones for union(), intersection(), accumulate(), and other simpler math functions.

View 3 Replies


ADVERTISEMENT

C++ :: Read List Of Random Numbers From Input File And Calculate Statistics?

Nov 11, 2013

I need my program to read a list of numbers from and input file, random.txt, and calculate the following statistics on those numbers:

A. The number of numbers in the file.
B. The sum of all the numbers in the file.
C. The average of all the numbers in the file.
D. The largest number in the file.
E. The smallest number in the file.

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>

[Code]......

This is what I have so far but I'm not sure if it is right. I can't get the input file to open.

View 3 Replies View Related

C++ :: Show All Composite Numbers 1 To 100 - 5 Columns?

Feb 25, 2013

This code is show all the composite numbers1 to 100. how can i add a limit of 5 column in this sample program??

#include<iostream>
#include<iomanip>
#include<conio.h>
using namespace std;
int main(){
int i,j;

[Code] ....

View 1 Replies View Related

C++ :: Print Square Roots Of Numbers With Rows And Columns

Mar 12, 2013

this is what i have so far

#include <iostream>
#include <cmath>
using namespace std;
int main () {
int v;

[Code] ....

im trying to get the program to print this as an example if the user enters 5 (the rounding of the decimal is optional).

1 1.41 1.73 2 2.24
1 1.41 1.73 2
1 1.41 1.73
1 1.41
1

why its not reading my for loop for rows its only doing columns ...

View 4 Replies View Related

C/C++ :: Program That Will Print Numbers In Columns From User Input

Oct 7, 2014

I tried to work on this program for while, but I am not able to get it to work

Directions:Write a program that reads an integer n from the user.

Display the first 100 numbers, with newlines every n numbers, using % operator

#include <stdio.h>
int main(void){
int a = 0;
int b = 99;
printf("Enter a number: ");
scanf ("%d", &a);

[Code] ....

When I run this code it asks me to enter a number. It doesn't matter what number I enter it gives me the numbers from 1 to 100 in one horizontal line.

I want this program to do something like this:

for example if the user enters n=6 the program should give:

0 1 2 3 4 5 6
7 8 9 10 11 12 13
and so on

View 2 Replies View Related

C++ :: Comparing Three Numbers And Display Largest

Oct 9, 2013

My display is producing:

Enter the first number:234
Enter the second number:2
Enter the Third number:3
The largest number is 3

#include <iostream>
using namespace std;
double larger(double n1, double n2, double n3);
int main() {

[Code] ....

View 1 Replies View Related

C :: Word Length Statistics For A Sentence

Oct 25, 2014

Write a program that calculates statistics on word length for a sentence. The sentence isterminated by a ',' For each found length of a word the number of words of that length is printed. Only those lengths that are found in the input are printed. Only letters from a-z or A-Z are allowed to form words. Words are separated by a space. No punctuation characters other than ',' are allowed. If any other input character is recognized or the input is longer than 80 characters the program displays "NOT VALID" (see Hints).

Note, that in the case that no word is present in the input, nothing is printed.

% u6_stats

Enter a sentence: Bolt was expected to use the super bark.

Length 2: 1
Length 3: 3
Length 4: 2
Length 5: 1
Length 8: 1

% u6_stats

Enter a sentence: Something wasn't right.
NOT VALID

Thats what i've already done.

Code:
#include <stdio.h>
#include <conio.h>
void main() {
char s[100];
int numOfWords, lengthOfWord = 0;

[Code] ....

So, the problem is that if i inpute a text like"abc abcd abc abc" the result will be like

"length 3: 3 length 4: 1 length 3: 2".

So when the program already compared 1st (here 3) element with others, this element will not be comparing again, but i have the 3d element with same length, and it that case, the program compare it with remained elements and print 2. How can i rework my code, if i don't wont to compare already compared elements.

Second problem is that i need to get results from lowest length till highest.

View 2 Replies View Related

C++ :: Program That Allows User To Enter Statement And Outputs Statistics?

Dec 12, 2013

a program that allows the user to enter a statement and outputs statistics; number of vowels, number of constants, percentage of vowels and constants, number of words, number of punctuation characters

View 2 Replies View Related

C/C++ :: Calculating Median And Mode In Movie Statistics Program

May 5, 2014

I am having trouble calculating the median and mode in a program that I am writing. When I run the program, lets say there are 5 students being surveyed. The input is as follows, Student #1 sees 2 movies, student #2 sees 6,student #3 sees 5 movies, student #4 sees 2 movies, and student #5 sees 1 movie. However, for the median, I get 5, because that is at element 2, and thus midway through the count, so the program interprets that number as the median. For the mode, even though 5 is repeated twice, the program displays that there was no mode, or displays "-1" (indicating no mode). Here is my code:

Write a program that can be used to gather statistical data about the number of movies college students see in a month. The program should perform the following steps:

A) Ask the user how many students were surveyed. An array of integers with this many elements then be dynamically allocated.

B)/> Allow the user to enter the number of movies each student saw into the array.

C) Calculate and display the average, median, and mode of the values entered.

Input Validation: Do not accept negative numbers for input.

#include <iostream>
#include <iomanip>
using namespace std;
// Function prototypes
double calculateMean(int *, int);
double calculateMedian(int *, int);
int calculateMode(int *, int);

[Code] .....

View 2 Replies View Related

Visual C++ :: Reading Records From Input File And Do Some Statistics

Oct 1, 2014

The program will prompt the user to enter a every student's first and last name, major ( of 4 choices CMPS MATH PHYSICS or EECE ), and grade. it's agreed that the professor will enter the name NoMore to stop the entry.

the program willl then store the info in a txt file. after closing the input file, the program will open it again read the records one at a time until end of file, and do some statistics including: highest grade, average grade, and highest average by major.

Finally the program will print the results....

View 6 Replies View Related

C++ :: Code For Sum Of Pandigital Numbers

Mar 25, 2013

I am a database developer and I am assigned with a task to finish it as someone left it in the middle.The number 1406357289 ,is a o to 9 pandigital number because it is made up of each of the digits of 0 to 9 in some order,using each digit only once, but it also has a rather interesting sub-string divisibility property. Let d1 be the 1st digit,d2 be the 2nd digit, and so on.In this way,we not the following;

d2d3d4=406 is divisible by 2
d3d4d5=063 is divisible by 3
d4d5d6=635 is divisible by 5
d5d6d7=357 is divisible by 7
d6d7d8=572 is divisible by 11
d7d8d9=728 is divisible by 13
d3d4d5=289 is divisible by 17.

Find the sum of all 0 to 9 pandigital numbers with this property.

View 5 Replies View Related

C :: Code That Will Store PID Numbers Of Child After A Fork?

Aug 8, 2013

I am currently trying to write a code that will store PID numbers of a child after a fork, I have to be able to enter an amount that will be created, so far I have managed to be able to get them to print (which puts me on the right path as far as I am concerned) but I am having issues. Using the following code:

Code:

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

[Code].....

View 3 Replies View Related

C/C++ :: Get Code To Sum A String Of Numbers Input From A File

Nov 5, 2014

This program gets input from a file and output to the screen and to a file. The difficulty I am having is summing the number I retrieve from the file for the individual numbers of sightings.

#include <fstream> // enables us to read and write files
#include <iostream> // for cin and cout
#include <cstdlib>
#include <string> // enables us to hold strings of characters
#include <cctype>
using namespace std;

[code].....

View 14 Replies View Related

C++ :: Program That Takes Baseball Players Statistics And Display Averages - Function Division

Oct 10, 2013

I was required to write a program that takes a baseball players statistics and displays there averages. I was required to make 3 function in the file to perform this tasks. my problem I am having a division problem in the SLG function. My compiler does not require the system ("PAUSE"); command.

OUTPUT
The player's batting average is: 0.347
The player's on-base percentage is: 0.375
The player's slugging percentage is:
(test)AB = 101
(test)Tot Base = 58
0.000

Code:
/* Batting Average Program
file: batavg1CPP.cpp
Glossary of abbreviations:
BA = batting average
PA = plate appearances
H = hits
BB = bases on balls (walks)

[Code] ....

View 3 Replies View Related

C++ :: Program To Extract Special Code From A List Of Numbers

Nov 1, 2013

I am a beginner and I ALWAYS have the toughest time doing I/O files. It's extremely frustrating. It "seems" it should be so simple. The program should find a code from a list of numbers. These numbers are from 0 - 9, and after each number is a space in the file. Your job is to extract a special code containing only 10 of those numbers. For the number to be part of the code, it should be divisible by 2. After extracting 10 numbers divisible by 2 for the code, write those 10 numbers to the file to form the expected code.

Input file is ("question.txt")
Output should be ("code.txt")

Should this contain a "for loop" or If/else ?

Here's what I did . .

/
// int numbers, total, counter;
ifstream inFile;
inFile.open ("question.txt");
outFile.open ("code.txt");
if (!inFile)

[Code] ....

View 2 Replies View Related

C++ :: Implement Source Code That Turns Numbers Into English Text

Apr 18, 2013

I have been working on the same problem as mp252 from an earlier thread and 4 days later, I appear to have it working. Mine only goes from 0-9999 though as I must move on!

Code:
#include <iostream>
#include <string>
int getThousands(int number);
int getHundreds(int number);
int getTens(int number);
int getUnits(int number);
void printNumber(int number);

[Code]......

I had a scrap of paper like a mad scientist trying to find relationships between numbers and the values that they would return through my functions. This is how I arrived at the conditions of my if statements in 'void printNumber'.

I have seen other code that allows a greater range but I can't quite follow it (yet):

C++ code by fun2code - 67 lines - codepad

View 1 Replies View Related

C :: Write A Code To Find All The Prime Numbers Before A User Entered Number

Apr 9, 2014

I am trying to write code to find all the prime numbers before a user entered number. I started with a working program and when I tried to create a function, it got all messed up.

Code:

#include <stdio.h>
int is_prime( int num );
int get_positive_integer(void);
int main( ) {
int upper; /* upper limit to check */
int num; /* current number to check */
int isprime;
/* used to flag if number is prime or not */

[Code]...

It says the error is on line 23

View 6 Replies View Related

C++ :: Write A Source Code That Find Smallest / Largest And Average Of Numbers From Array

May 13, 2014

im trying to write a source code that find the smallest, largest and average of numbers in array. the code runs fine, but it is not giving the highest number and the the average should include only four number excluding highest and smallest number from the array.

void OlympicJudging() // Olympic Judging {
int numbers [6];
double average, sum = 0;
int temp;
for(int i = 0; i < 6; i++){
cout << "Please type a value for scores: ";
cin >> numbers[i];

[Code]...

View 5 Replies View Related

C :: How To Make Sum Columns

Oct 17, 2013

I have this code it sums the rows now I need it so it would sum all the columns in the output and put it in row 8 of the outcome. How would I go about doing that?

Code:

#include Code: "stdio.h"
#include "stdafx.h"
int main(void) {
int number[8][7];
}

[code]....

View 1 Replies View Related

C/C++ :: Output In 3 Columns?

Apr 8, 2015

I have this code down except I'm very confused how to make the output come out in 3 columns.

#include<iostream>
#include<fstream>
using namespace std;
int main() {
int i, j, n, flag = 0, prime_number = 0, temp;
cout << "Enter first prime numbers that will be used or -1 to end:" << endl;
[Code] ......

My output right now is:

Enter first prime numbers that will be used or -1 to end: 20
Twin Prime Number : (3,5)
Twin Prime Number : (5,7)
Twin Prime Number : (11,13)
Twin Prime Number : (17,19)

But what I want is:
1. {3;5} 2.{5,7} 3.{11,13}

4. {17,19}

View 1 Replies View Related

C :: Print Out - Array Code And Pseudo Code?

Apr 15, 2013

I have assignment which requires me to print out and array code and a pseudo code. I dont no what a pseudo code is,.

View 2 Replies View Related

C :: Creating Rows And Columns

Mar 6, 2015

how to make the it all work later...but in the mean time how can i get this to display this? Note it has to be made using as a console program. The "Description" and "Cost/ib" collums will be referenced through use of a header file. all else is done by user input and calculations.

View 2 Replies View Related

C++ :: Printing Arrays In Columns

Jun 25, 2013

I'm working with arrays and I get them column by column and need to print them. I as there a way to print in columns?

For example: I produce an array of A, B and C from a loop and then need to print them in one column and the go to the next column ....

so in the end I shall have an output like this:

A E
B F
C G
D h
... ...

My arrays are too long (over 50K) so I cant just store the arrays and then print them. I need to produce each column array, print them and delete it and go to the next column.

View 1 Replies View Related

C++ :: 2D Vector Adding Columns

Apr 10, 2014

I have a basic question regarding 2d vectors. The following code makes a 2d vector and fills it with a matrix of integers. The vector tempVector3 gets added as a new row to the matrix. But what if I wanted to add the tempVector3 as a new column instead. How would this be done in the simplest way?

#include<iostream>
#include<vector>
int main(){
std::vector<std::vector<int>> numbers;
std::vector<int> tempVector1;
tempVector1.push_back(2);

[Code] ....

View 5 Replies View Related

C++ :: Storing Data From 2 Columns In CSV

Oct 17, 2013

I have a file that can range from 100 rows to 10000+ that is comma delimited with 8 columns. The first 32 rows (also comma delimited) will always be ignored (geographical header information). I will be wanting the data from column2 and column3.

For this I believe I would need (2) For Loops as such:

for(i=0;i<2;++i) {
getline("do something here");
}

and

for (i=0;i<3;++i) {
getline("do something here")
}

Also would using a vector or array with dynamic storage be the better way to tackle this problem? Where to start from after accessing the file.

View 19 Replies View Related

C++ :: How To Add Labels For Different Columns Of Data

Sep 20, 2014

I am trying to add labels to the data. I have data in a file divided by space:

1 2 3 4 5 6
7 8 9 10 11 12

I need it to look like this:

label_1: 1 2 3 4 5
label_2: 6
label_1: 7 8 9 10 11
label_2: 12

How can this be done?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved