« first day (653 days earlier)      last day (3371 days later) » 

10:02 PM
Why does the number of lines matter?
 
Tell him to cresate a standardDeviation method.
Then, he doesn't need to worry about how many lines it is, really.
And if it is one line, so long as it is the right formula it doesn't really matter.
Because once right, he never needs to worry about it again.
Chancellors list twice, Deans list once.
(I would have been a Chancellor again, less than 1 percent away, but my professor wasn't prepared for the class.)
Sorry for the interruption, the email just came in.
 
@Hosch250 computes the right result, and computes it efficiently.
 
True.
But, the standard deviation formula is fairly simple.
It does use the Summation operator, though, so huge data sets could be a problem.
 
What is the formula?
I hate looking at the math articles on Wikipedia.
 
10:13 PM
@Pimgd he's not allowed to use numpy, i take it?
 
So, how to turn that into a function...
 
Just pass N.
 
That doesn't make sense. But I mean a function in the programming sense of the word.
 
Here, I'll write one quick and post it for review.
 
10:16 PM
You'd pass an array of integers/floating-point numbers.
The function should take an array and return a floating point value.
 
Oh, yeah.
Was thinking of the standard deviation of 1-N, for some reason.
 
Okay.... I'm on my laptop... which is Linux, and I just figured out how to do command line compilation of c programs...
 
Congrats? :)
(I don't know if that's a hard thing or not)
 
It's not.
I've just never done it before.
 
0
Q: Trabb Pardo – Knuth - Algorithm in streams

rolflTrabb Pardo and Knuth devised this simple procedure as a way to explire the functionality of various languages. The wiki page: Trabb Pardo–Knuth algorithm describes it as: The Trabb Pardo–Knuth algorithm is a program introduced by Donald Knuth and Luis Trabb Pardo to illustrate the evolution ...

 
10:30 PM
@nhgrif Well, there's a first for everything :)
 
For future reference, codereview.stackexchange.com is a good place for questions like this (where in this case the problem was a mere typographic error in the code). In fairness, that may have been hard to catch, but the real problem has nothing specifically to do with while loops or even FITS really. — Iguananaut 46 secs ago
 
Morning
 
@Duga ARE YOU NUTS!?
3
 
Morning.
 
@Iguananaut For future reference, Code Review is not a place for questions like this. Code Review requires code to be working as intended already. — Simon André Forsberg 1 min ago
 
10:37 PM
@SimonAndréForsberg Nope, it is Iguananaut who is nuts.
 
@SimonAndréForsberg he wouldn't understand that slang i guess ;P
 
@Hosch250 oh, right.
 
@nhgrif I did it.
One line, using Linq.
 
he even has 171 reputation on CR... written two answers.
 
return Math.Sqrt(numberSet.Sum(x => Math.Pow(x - numberSet.Average(), 2)) / (numberSet.Count));
Standard deviation for population ^^
return Math.Sqrt(numberSet.Sum(x => Math.Pow(x - numberSet.Average(), 2)) / (numberSet.Count - 1));
 
10:39 PM
And how efficient is that?
 
Standard deviation for sample.
 
How many times do you calculate the average for example?
 
I don't know.
Just once.
Oh, once per time.
 
Yeah, exactly.
 
Well that was just the oneliner.
I'll post my first solution in a sec.
 
10:40 PM
And as I asked earlier, why does the number of lines matter?
 
It doesn't.
I didn't say it did.
        static double SampleStandardDeviation(List<double> numberSet)
        {
            double mean = numberSet.Sum() / numberSet.Count;

            return Math.Sqrt(numberSet.Sum(x => Math.Pow(x - mean, 2)) / (numberSet.Count - 1));
        }
But, I think Linq would probably compile that out
Let me run it with a huge data set and a timer.
 
@Iguananaut Sounds like you might want/need to read Be careful when recommending Code Review to askersSimon André Forsberg 1 min ago
 
This is why I like Xcode.
You can use Xcode instruments to see exactly how many times something is called...
 
You can in VS too, but I don't remember how.
I've done it before.
 
###Code Review misguide
No, this does not belong on Code Review. Please read [Be careful when recommending Code Review to askers](meta.stackoverflow.com/questions/253975/…)
^^ Stack Overflow auto-comment
 
10:47 PM
@nhgrif Interestingly enough, the one-liner is much faster than when you calculate the mean beforehand.
Well, sometimes.
OK, it is faster for small data sets.
I didn't have a large enough dataset to affect it yet.
 
#include <time.h>
#include <math.h>
#include <stdio.h>

const int kVALUES = 100000;

double getAverage(int arr[], int size) {
	int i;
	double sum;

	for (i = 0; i < size; ++i) {
		sum += arr[i];
	}

	return (sum / size);
}

double differenceSquared(int a, int b) {
    return pow(a - b, 2);
}

double standardDeviation(int arr[], int size) {
    double avg = getAverage(arr, size);
    int i;

    double runningTotal = 0;

    for(i = 0; i < size; ++i) {
        runningTotal += differenceSquared(arr[i], avg);
I have no idea if I'm calculating the right value or not.
 
I made a List so big it wouldn't compile :(
 
@Hosch250 wouldn't... compile :|
 
Yup.
 
can you elaborate?
 
10:51 PM
I made a massive List<double>
Too long to post in the message here.
 
like new List<double> { 1, 2, 1, 6 1, ... } ?
 
Yeah.
 
like, all the numbers in the source code
right
 
So, it won't compile.
 
hey @nhgrif, I assume there is a reason, but why exactly do you force objects in your BiDiDictionary to conform to NSCopying? would it be possible for the dictionary to work at all without that requirement?
 
10:52 PM
@Hosch250 Enumerable.Range(0, 10000).ToList()
 
Why wouldn't you just fill a list with rand?
 
OK, thanks.
Oh, I don't know.
 
@bazola NSDictionary keys must conform to this protocol?
 
ah, yeah, makes sense :)
 
NSDictionary values don't have to... but in our dictionary, keys are also values and values are also keys.
 
10:54 PM
are you planning to look at the edge cases and edit the question? If not if I post an answer I'd mostly be talking about unit testing etc
 
I can't look at it at the moment (I'm not on my mac). And when I was most recently I forgot about the edge case. You should post a review and comment on the edge case (particularly if you have a solution)
 
0
Q: How can I use a base class for integration test

QuoterSee here my base class for integration test: [TestClass] public class BaseIntegrationTest { protected readonly ApplicationDbContext _dbContext; public BaseIntegrationTest() { _dbContext = new ApplicationDbContext("DefaultConnectionTest"); } [ClassInitialize] pub...

 
@nhgrif Feel free to say all you want:
0
Q: Calculating Standard Deviations

Hosch250We were discussing Standard Deviations in chat, so I decided to write a standard deviation calculator: static double PopulationStandardDeviation(List<double> numberSet) { double mean = numberSet.Average(); return Math.Sqrt(numberSet.Sum(x => Math.Pow(x - mean, 2)) / numberSet.Count); ...

 
Well, @Hosch250, mine takes somewhere between 0 and 1/100th of a second... I have no idea what I'm doing in C, so I don't know if my timer is accurate enough... nor have I been able to figure out how to create an array larger than uint max (is it possible in C?)
#include <time.h>
#include <math.h>
#include <stdio.h>

const unsigned int kVALUES = 65535;

double getAverage(int arr[], int size) {
	int i;
	double sum;

	for (i = 0; i < size; ++i) {
		sum += arr[i];
	}

	return (sum / size);
}

double differenceSquared(int a, int b) {
    return pow(a - b, 2);
}

double standardDeviation(int arr[], int size) {
    double avg = getAverage(arr, size);
    int i;

    double runningTotal = 0;

    for(i = 0; i < size; ++i) {
        runningTotal += differenceSquared(arr[i], avg);
 
I don't know.
 
10:59 PM
@nhgrif alright. I haven't looked at it long enough to come up with a solution, but if I manage to come up with one I will do so
 
I also don't know whether or not my calculation is even accurate.
 
I've never used C.
You are calculating the standard deviation for a sample.
Yes, it is right as far as I see.
 
That indentation is terrible (in my paste)
 
It is essentially the same as mine, but I use Linq and lambdas instead.
Why don't you post yours for review too?
 
Because I wrote mine in a text editor...
 
11:02 PM
So?
 
You really shouldn't ask:
> Would they feasibly work with large data sets, on the order of millions of items?
 
Why not?
Some data sets are that large?
 
You should just test it yourself?
 
0
Q: Calculating Standard Deviations

Hosch250We were discussing Standard Deviations in chat, so I decided to write a standard deviation calculator: static double PopulationStandardDeviation(List<double> numberSet) { double mean = numberSet.Average(); return Math.Sqrt(numberSet.Sum(x => Math.Pow(x - mean, 2)) / numberSet.Count); ...

 
I could, and they would run.
What I am trying to ask is whether it is an optimal solution.
Changed wording.
 
11:06 PM
In VB: Dim TestList As New List<Integer>(Int.MaxValue)
    For i As Integer In 0 To Int.MaxValue - 1
        TestList(i) =  CInt(Math.Floor((Int.Max) * Rnd()))
    Next

    Dim result As Double = PopulationStandardDeviation(TestList)
Hmm. It seems like the tag is a little pointless.
 
I should get Inquisitive with this question.
@mjolka Have a +1 after RESET!
 
@Hosch250 i tried the method @200_success linked to in a console app, and it throws the exception This function can only be invoked from LINQ to Entities.
 
Huh?
Let me run it.
 
static void Main(string[] args)
{
    Console.WriteLine(EntityFunctions.StandardDeviation(new double[] { 1, 2, 3 }));
}
 
@Hosch250 s/RESET!/RELOAD!/
or technically, s/SET/LOAD/ <--- same result.
 
11:17 PM
@mjolka I don't even have access to that function.
There is no such thing as System.Data.Objects
 
@Hosch250 add a reference to System.Data.Entity.dll
 
OK.
 
hi
 
Hi.
 
this is a programmer's chat room, ya?
 
11:20 PM
@mjolka I did that, and now I has System.Data.Objects
@WikiWitz Looks like it, doesn't it?
 
@Hosch250 sucks, im actually looking for electronics related help but their chat rooms are not active
 
@mjolka Nevermind, solved it.
Oh.
 
someone here know electronics-related stuff that might be able to help?
 
I know a bit of electronics, but...
 
Welcome @WikiWitz. This is a chat room that are mostly about the Code Review Stack Exchange site. If you are looking for electronics-related stuff, don't expect much help from here.
 
11:23 PM
any recommendations?
sorry
 
@mjolka No luck. Same error.
last message	14 hours 50 minutes ago
 
@mjolka afaik you were working on a little settings type of window (for Authentication I guess)
 
@Mehrad yep that's right
 
@mjolka was wondering which approach you've used to link your View to your ViewModel (if you use MVVM for sure)
 
11:36 PM
@Mehrad i'm using MVVM, not sure if that answers your question though
 
a DataTemplate, or referring a DataContext in the View's XAML
 
datacontext in the view's xaml
 
great. I wanna switch to that method as well
would you be able to give me the synatax for it.
 
@Mehrad well, for mockup that is. i need to integrate it with the proper codebase, which is using MVVM light and a ViewModelLocator
 
Would save me lots of time looking around if you have it handy
 
11:38 PM
<Window.DataContext>
    <local:LicenseViewModel/>
</Window.DataContext>
 
That's how I was expecting it to be. Great
Good that I asked
 
@Mehrad if you forget the syntax, you can set the datacontext in the properties window
 
Oh... never done that before. That's clever
 
There are three way I found to set it.
First, in code behind - this.DataContext = ...;
Second, when you create the page:
<Window
        DataContext="..." />
 
So far I have used UserControls rather than Windows and always used a DataTemplate method.
 
11:41 PM
Third, like @mjolka does.
 
@Mehrad i don't know enough to recommend a particular way. i'm just winging it. i've read people arguing that setting the DataContext in the code behind is bad, but i couldn't tell you why exactly
 
@Hosch250 there are all three approaches for the single method though. There are multiple others
 
Yeah.
 
@mjolka, yep. No code behind. at least not until it's absolutely necessary. This method that you're using is a very neat and simple one that's why I am switching
If you're using branded MVVM platforms they normally have Locators like how MVVMlight does. but I don't use them either
Just my own home brew MVVM
tasting like a developers arm pits : )))))))))) (Gross)
Cheers guys... I got all I needed and as always learned something new
 
@Mehrad i chose MVVM Light early on, as it seemed to be very popular. ran into some troubles early on with the ViewModelLocator, as the product i'm working on is an add-in, so you can't set the ViewModelLocator in App.xaml (there's no App.xaml). i sort of wish i'd started off doing things the basic way, i think my understanding of mvvm would be better
 
11:47 PM
I don't use any helper.
But, I've kind of gotten in a groove with my app because here I am stuck updating it, and I probably should be writing a more complex one.
I could make it more complex, but that would mess the UI up.
 
@Hosch250 have you thought any more about using git?
 
Yes.
Do you have to pay?
 
@Hosch250 nope
 
Good.
I'll look into it.
 
@Hosch250 install chocolatey, if you haven't already, then cinst git i think should do it
 
11:51 PM
What is chocolatey?
A version of Android?
 
@Hosch250 an easy way of installing and updating applications
 
I'll do it by hand like I always do.
 
@mjolka if you wanna familiarize yourself with basics definitely put some time and check that Article I mentioned before from JoshSmith. That sample application was also a sample for that Article that I have shared on OneDrive with you the other day. It's a piece of art that article and everytime I read it I learn something new
 
@Hosch250 fair enough, but if you want to look into it chocolatey.org
 
Sure.
 
11:52 PM
Of all the human-centric measurements, I just found the most useful one. A gou.
 
@Mehrad thanks, i'll try to set aside some time tonight to read through it
 
So, do I install it in Windows?
Or, do I get it through the VS store?
 
@Hosch250 are you familier with Apt-get ?
 
Nope.
 
@nhgrif gou? as appose to ?
@Hosch250 Windows. There is command line and Power shell command for installing it
whichever you wish
 
11:54 PM
OK.
 
A gou is approximately 180ml
It's a measurement of volume.
180ml supposedly represents the amount of dried rice an adult will consume in a day.
 
@Hosch250 One of the the things linux is really proud of are applications called package managers like Apt-get. everything get's installed and updated into Linux using this manager. You need one command to Update all your installed softwares as appose to 100 programs giving you warnings and pop ups every second hour. Choco implements a similar approach for windows.
 
OK.
Installing Chocolatey now.
 
thanks for a good recommendation of @mjolka now I use Choco all the way and I can't be happier
 
@Mehrad glad to hear it :)
 
11:57 PM
Actually, maybe not.
 
0
A: How should the [beginner] tag be used?

nhgrifI'm not entirely certain I completely like this tag at all, actually. Personally, I don't tend to pay attention to whether or not the tag exists when I post answers. Sometimes, questions that probably should use the tag omit it (for whatever reason), and other times, questions that probably don...

 
@nhgrif I am kinda into Metrology and follow these type of things. and this one never heard of. As long as it won't show up in the text books for measuring circuit boards I am happy :D
 
@mjolka Do I want the Git-1.9.5-preview20141217.exe file?
 
@Mehrad So, it's like the Mac app store... except, you don't have to ask someone if they've heard of it.
@Mehrad It's a food measurement. It originates in Japan, I think, as a measurement of rice, etc.
 
OK, apparently it is the stable release.
 
11:59 PM
RELOAD!
 
@Duga No!
 

« first day (653 days earlier)      last day (3371 days later) »