Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer

nielsm posted:

What happens the remaining 29.5% of the time?

You don't win anything.

Adbot
ADBOT LOVES YOU

ulmont
Sep 15, 2010

IF I EVER MISS VOTING IN AN ELECTION (EVEN AMERICAN IDOL) ,OR HAVE UNPAID PARKING TICKETS, PLEASE TAKE AWAY MY FRANCHISE

LOOK I AM A TURTLE posted:

You don't win anything.

Doesn't match the original:

quote:

The slot machine only has 3 results, you get either prize #1 worth $13, prize #2 worth $20, or prize #3 which is worth $100.

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer

ulmont posted:

Doesn't match the original:

Ok, I guess I just assumed it was possible to not win, since if $13 is the minimum return you might as well make the bet $2 and reduce all the prices by $13, but whatever. It doesn't really change the main point, which is that there are multiple correct answers.

Eela6
May 25, 2007
Shredded Hen
There are infinitely many solutions.

Let's call the probability of the $13 win a, the $20 win b, and the $200 win c. We'll call the gambler's profit p

Then


When does the gambler make money? Whenever p is positive.

So then


So we make money when 7b + 187c <=2

Eela6 fucked around with this message at 04:12 on Feb 9, 2018

School of How
Jul 6, 2013

quite frankly I don't believe this talk about the market

Eela6 posted:

There are infinitely many solutions.

Let's call the probability of the $13 win a, the $20 win b, and the $30 win c. We'll call the gambler's profit p

Then


When does the gambler make money? Whenever p is positive.

So then


So we make money when 7b + 187c <=2

Thanks for the help. It was my intuition that there would be multiple solutions. If we limit the profitability of the machine so that the house only makes 5% profit, does that result in a single solution?

I need this for a game I'm creating. There is a casino aspect to the game, and I want the odds to favor the house, but not so much that users get screwed.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

School of How posted:

Thanks for the help. It was my intuition that there would be multiple solutions. If we limit the profitability of the machine so that the house only makes 5% profit, does that result in a single solution?

I need this for a game I'm creating. There is a casino aspect to the game, and I want the odds to favor the house, but not so much that users get screwed.

No. There are infinite solutions for (almost) any expected return (and the exceptions are uninteresting for your purposes).

If you set a fixed ratio between two of the results, like that the $20 win is twice as likely as the $30 win, then there's a unique solution for a given expected profit.

Linear Zoetrope
Nov 28, 2011

A hero must cook

School of How posted:

Thanks for the help. It was my intuition that there would be multiple solutions. If we limit the profitability of the machine so that the house only makes 5% profit, does that result in a single solution?

I need this for a game I'm creating. There is a casino aspect to the game, and I want the odds to favor the house, but not so much that users get screwed.

Basically, since the probability of the third result ends in more loss than the second result, you can offset making result 1 more likely by also making result 3 more likely at the expense of result 2's probability. (And, conversely, offset the loss by decreasing the first result's probability by making p2 a bit more likely at the expense of p3). Basically, if you make it more likely for them to win, you can "fix" the overall payout by making it so when they lose, they tend to lose more on average. This gets arbitrarily complex as you add more types of payouts, but the general idea that you can rig a given return by choosing how much they win or lose holds.

This gives you a good amount of power as a designer, though, because this means that even if the average payout is the same you can tweak the player's perception of how much fun it is by making certain types of payouts more frequent, even if under the hood the expected return is exactly the same. A way to solve this, then, would be to choose a suitable frequency for the player to win and then solve for the other two in terms of each other since now you only have two variables.

E: Wait, rereading p1 is the loss and p2/p3 are small/large gains, but the same general idea holds in reverse.

Linear Zoetrope fucked around with this message at 04:01 on Feb 9, 2018

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

School of How posted:

Imagine there is a slot machine. The cost to pull the handle is $15. The slot machine only has 3 results, you get either prize #1 worth $13, prize #2 worth $20, or prize #3 which is worth $100. The machine needs to be designed to assign prizes based on a probability that the machine can be operated profitably. In order for the machine to be profitable, prize #1 must be the most common, and prize #3 must be the least common prize. How can I calculate the probability of each prize in order to maintain break even? Is there such a formula I can plug the prize values into to get each probability? Maybe this is more of a math problem than a computer problem, but I need some python code that calculates this probability.

Prize #2 could be the least common (even 0%) and you could still have a profitable machine..

Eela6
May 25, 2007
Shredded Hen

School of How posted:

Thanks for the help. It was my intuition that there would be multiple solutions. If we limit the profitability of the machine so that the house only makes 5% profit, does that result in a single solution?

I need this for a game I'm creating. There is a casino aspect to the game, and I want the odds to favor the house, but not so much that users get screwed.

Let's find out. 5% of $13 is 0.65 cents, so we want to set -p=0.65. (That is, we want our victim customer to lose a 5% of their money every pull, on average)
Accordingly:



This describes the family of solutions.

John Wick of Dogs
Mar 4, 2017

A real hellraiser


Hey I'm trying to do some stuff in Excel but don't really understand VBA much, could anyone help?

Essentially, I write values from a program into a print work sheet. This sheet has some images in it that I'm basically using as watermarks. I currently have multiple tabs, each with their own watermark, and I write to the tab with the right one by checking certain conditions, and then print. But my sheet is growing too large and unwieldy.

What I would rather do is simply put every watermark on the same page and hide them all. Then use VBA script to check sone values I'll write outside the print area, and pick a different watermark to make visible based on those conditions.

Unfortunately I don't really understand either how to check the values, what a conditional statement looks like in VBA, or how to reference the images in my file and change their property to visible.

Does anyone know how to do these things?

mystes
May 31, 2006

Al Borland Corp. posted:

Hey I'm trying to do some stuff in Excel but don't really understand VBA much, could anyone help?

Essentially, I write values from a program into a print work sheet. This sheet has some images in it that I'm basically using as watermarks. I currently have multiple tabs, each with their own watermark, and I write to the tab with the right one by checking certain conditions, and then print. But my sheet is growing too large and unwieldy.

What I would rather do is simply put every watermark on the same page and hide them all. Then use VBA script to check sone values I'll write outside the print area, and pick a different watermark to make visible based on those conditions.

Unfortunately I don't really understand either how to check the values, what a conditional statement looks like in VBA, or how to reference the images in my file and change their property to visible.

Does anyone know how to do these things?

quote:

"a print work sheet.... I currently have multiple tabs"
First, if you mean a document with multiple tabs, the document is a "workbook" and the tabs are "worksheets" in Excel terms (I mention this because it could cause a lot of confusion later if you're trying to access them from VBA).

It sounds like you will want to do something like this (I haven't been using vba much lately so I might have some of the syntax wrong)
code:
Dim wb As Workbook
Dim ws as Worksheet
set wb = Workbooks.open("asdf.xlsx")
for each ws in wb.sheets
    if ws.range("A1").value = 5 then
         ws.Shapes("Image 1").visible = true
    end if
next ws
Edit: Also there's an excel thread: https://forums.somethingawful.com/showthread.php?threadid=3132163

mystes fucked around with this message at 16:06 on Feb 9, 2018

John Wick of Dogs
Mar 4, 2017

A real hellraiser


Thanks, that little snippet very succinctly has shown me how to do the three things I didn't understand. I'll check out that thread.

El Generico
Feb 3, 2009

Birds revere you and consider you one of their own.

You are welcome in their holy places.
I want to know which of my tweets has been liked or replied to by the most famous person (the person with the most followers, I assume would be the way of knowing). Is there a Twitter API script to do this?

Mr Shiny Pants
Nov 12, 2012
Anybody seen this: https://hackernoon.com/im-harvesting-credit-card-numbers-and-passwords-from-your-site-here-s-how-9a8cb347c5b5

I thought it was a good read, especially after trying to get into Web frontend development and getting lost in all the stuff it seems to come with right now.

Acidian
Nov 24, 2006

I need to do some work on updating a book database, and instead of using an external developer (expensive), I might try and do it myself.

I want to get information from an XML file, CSV file or a .txt file (which would be sepparated by comma or tab), which will be headed by an ISBN number (Which will be my identifyer), then I want to find the same ISBN in an excel list I have exported from my database, then move information from the CSV/XML/TXT file, to the correct cell (all cells will be to the right of the ISBN). An example would be moving information about author from a predesignated field in the CSV/XML/TXT to the designated "author" field in the same row as the identifyer (ISBN) in my excel sheet.

I am thinking that the best way to do this would either to create a script in Excel, or to create a program in python to read the file and inserting it into the excel file?

I do not know how to script in Excel, other than some copy pasting of macros, and I have only done some really really basic python in a bioinformatics course, so I will basically teach myself how to do it. What do you guys think is the best option for me?

Volguus
Mar 3, 2009

Acidian posted:

I need to do some work on updating a book database, and instead of using an external developer (expensive), I might try and do it myself.

I want to get information from an XML file, CSV file or a .txt file (which would be sepparated by comma or tab), which will be headed by an ISBN number (Which will be my identifyer), then I want to find the same ISBN in an excel list I have exported from my database, then move information from the CSV/XML/TXT file, to the correct cell (all cells will be to the right of the ISBN). An example would be moving information about author from a predesignated field in the CSV/XML/TXT to the designated "author" field in the same row as the identifyer (ISBN) in my excel sheet.

I am thinking that the best way to do this would either to create a script in Excel, or to create a program in python to read the file and inserting it into the excel file?

I do not know how to script in Excel, other than some copy pasting of macros, and I have only done some really really basic python in a bioinformatics course, so I will basically teach myself how to do it. What do you guys think is the best option for me?

If you already have the book data in a database (I assume a relational database? MySQL or something similar?), why bother exporting it to Excel? Work with the database directly. Then you can use whatever language you're comfortable with (if none, python would be a decent start for a beginner). If you absolutely have to use Excel, then I would think that you pretty much have to use Excel's VBA. There are libraries out there that can manipulate Excel sheets (Apache POI for Java for example), but for a beginner VBA is probably the easiest way.

Acidian
Nov 24, 2006

Volguus posted:

If you already have the book data in a database (I assume a relational database? MySQL or something similar?), why bother exporting it to Excel? Work with the database directly. Then you can use whatever language you're comfortable with (if none, python would be a decent start for a beginner). If you absolutely have to use Excel, then I would think that you pretty much have to use Excel's VBA. There are libraries out there that can manipulate Excel sheets (Apache POI for Java for example), but for a beginner VBA is probably the easiest way.

The data is currently in a SQL database, but I do not have access to it directly. I have to export it to excel, then I can import again via excel. I can double check with the company maintaining the server. Anyway, we will be changing system in a couple of months, and I think I will have access to the SQL database directly in the new system (if I ask for it). However, I do not want to wait until it is in place before I start this work. Is VBA very similar to basic/visual basic?

I guess you can't use python to read and write into excel files?

Getting komma sepperated information into excel is relatively easy, so I guess the easiest vill be to use VBA to sort it from one table to the other within the same sheet.

Edit: Is there another programming language that I could use? I feel like learning VBA is a bit limiting for what I can do with it in the future, so if I am going to spend alot of time learning somthing then VBA seems uninteresting, but if I could teach myself C++ (I do know a little C++ and Java), or javascript, then that would be better. Maybe the easiest solution is exporting the excel file to txt, then manipulating a txt file with all the information in python, then import back into excel, then back into the database.

Acidian fucked around with this message at 16:43 on Feb 12, 2018

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
You can use python to muck with Excel files. A quick search turns up http://openpyxl.readthedocs.io/en/stable/

I’ve done it in the past using pywin32, I do not suggest this approach unless you have exhausted all alternatives.

Volguus
Mar 3, 2009

Acidian posted:

The data is currently in a SQL database, but I do not have access to it directly. I have to export it to excel, then I can import again via excel. I can double check with the company maintaining the server. Anyway, we will be changing system in a couple of months, and I think I will have access to the SQL database directly in the new system (if I ask for it). However, I do not want to wait until it is in place before I start this work. Is VBA very similar to basic/visual basic?

I guess you can't use python to read and write into excel files?

Getting komma sepperated information into excel is relatively easy, so I guess the easiest vill be to use VBA to sort it from one table to the other within the same sheet.

Edit: Is there another programming language that I could use? I feel like learning VBA is a bit limiting for what I can do with it in the future, so if I am going to spend alot of time learning somthing then VBA seems uninteresting, but if I could teach myself C++ (I do know a little C++ and Java), or javascript, then that would be better. Maybe the easiest solution is exporting the excel file to txt, then manipulating a txt file with all the information in python, then import back into excel, then back into the database.

Oh, so if you want to learn a programming language to use after this particular endeavor, then VBA is probably not what you want. Like pokeyman said, python can manipulate Excel files and in Java there is the excellent Apache POI library. Pick your poison.

The Fool
Oct 16, 2003


You can work with Excel using COM from any .NET language. So C# and PowerShell are both reasonable candidates.

If you want to do python, I'd consider reading this: https://automatetheboringstuff.com/chapter12/

mystes
May 31, 2006

The Fool posted:

You can work with Excel using COM
Don't actually do this.

Ranzear
Jul 25, 2013

I'd sooner take a clean mysqldump and bring that into SQLite so it can be just as portable as any excel file. Then, again, you can use whatever language you want as long as it has a mysql driver.

Minimum chance for them to gently caress up the export, too.

LongSack
Jan 17, 2003

mystes posted:

Don't actually do this.

Agreed. There are Nuget packages for C# for both excel (EPPlus) and for handling CSV files (CSVHelper, I think) and both work quite well and are fairly straightforward to use. That is, EPPlus is quite straightforward, the other a little less so.

downout
Jul 6, 2009

Acidian posted:

I need to do some work on updating a book database, and instead of using an external developer (expensive), I might try and do it myself.

I want to get information from an XML file, CSV file or a .txt file (which would be sepparated by comma or tab), which will be headed by an ISBN number (Which will be my identifyer), then I want to find the same ISBN in an excel list I have exported from my database, then move information from the CSV/XML/TXT file, to the correct cell (all cells will be to the right of the ISBN). An example would be moving information about author from a predesignated field in the CSV/XML/TXT to the designated "author" field in the same row as the identifyer (ISBN) in my excel sheet.

I am thinking that the best way to do this would either to create a script in Excel, or to create a program in python to read the file and inserting it into the excel file?

I do not know how to script in Excel, other than some copy pasting of macros, and I have only done some really really basic python in a bioinformatics course, so I will basically teach myself how to do it. What do you guys think is the best option for me?

EPPlus is pretty great with c#.

You say that a file 'will be headed by an ISBN number' - what does this mean? The file name is an ISBN number? If it's a row in an CSV file, then you can just open the CSV in excel, manually copy the data to a target file, manually copy the excel list data from the source the other file to the target file, and use excel functions to match the data in the target file. The excel post can probably help (https://forums.somethingawful.com/showthread.php?threadid=3132163), and if you can then the excel functions right then they will work for any future exports, etc. Automating it would probably require coding.

I'd think more details are required for knowing what will work.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Wouldn't it be easier to just export the data from Excel as CSV, then make something that reads that and the other CSV file and merges them somehow, and then save the results for importing to Excel or whatever? Seems like less hassle than trying to work with Excel directly

e- or does this need to be run often on live data or something

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

The functional thread is closed for some reason, like a burrito, so I'll post this here: there's a bunch of O'Rly functional books in a Humble Bundle right now if anyone's into that

Any of them any good?

Love Stole the Day
Nov 4, 2012
Please give me free quality professional advice so I can be a baby about it and insult you
I only ever hear great things about the Rust one

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Real World Haskell is supposed to be pretty good, but it's a decade old and doesn't talk about the latest and greatest language features.

Acidian
Nov 24, 2006

Thank you guys, I really didn't expect this much help with my question.


baka kaba posted:

Wouldn't it be easier to just export the data from Excel as CSV, then make something that reads that and the other CSV file and merges them somehow, and then save the results for importing to Excel or whatever? Seems like less hassle than trying to work with Excel directly

e- or does this need to be run often on live data or something

I think this is the best solution. I can export the data easily enough, and import it back into excel after manipulating the target file. I think I can learn enough Python to do this relatively easily.

I need to do this manually until we have the new system in place, then I will read the files straight into the database.

Eela6
May 25, 2007
Shredded Hen
That Rust book is excellent. I would not consider it a functional programming book so much as a language reference for systems programmers.

Mr Shiny Pants
Nov 12, 2012
Hmmm no F# book, that's a shame. The Erlang one looks nice though.

Casual Encountess
Dec 14, 2005

"You can see how they go from being so sweet to tearing your face off,
just like that,
and it's amazing to have that range."


Thunderdome Exclusive

so i'm tasked with consolidating 10 year old excel documents into a database for what will be a few different email newsletters and i'm trying to find a way to scrape existing university staff directories of ours and a few other institutions so I can update the database with current info. otherwise I am literally cutting and pasting

what's the best way to automate this and just give it a series of names to output data for

Eela6
May 25, 2007
Shredded Hen
It's high time I actually learned Java. What's a good Java book for a somewhat experienced developer who is new to the language? My strongest languages are Python and Go, if it matters.

downout
Jul 6, 2009

Casual Encountess posted:

so i'm tasked with consolidating 10 year old excel documents into a database for what will be a few different email newsletters and i'm trying to find a way to scrape existing university staff directories of ours and a few other institutions so I can update the database with current info. otherwise I am literally cutting and pasting

what's the best way to automate this and just give it a series of names to output data for

Do you have any programming experience?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Casual Encountess posted:

so i'm tasked with consolidating 10 year old excel documents into a database for what will be a few different email newsletters and i'm trying to find a way to scrape existing university staff directories of ours and a few other institutions so I can update the database with current info. otherwise I am literally cutting and pasting

what's the best way to automate this and just give it a series of names to output data for

The documentary film "The Social Network" includes a brief chapter on scraping university directories.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

pokeyman posted:

The documentary film "The Social Network" includes a brief chapter on scraping university directories.

Also, if you're interested in methods for scraping the details and output of a bunch of pedantic morons, might I suggest the Awful family of applications? :v:

(not you, dear reader)

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Eela6 posted:

It's high time I actually learned Java. What's a good Java book for a somewhat experienced developer who is new to the language? My strongest languages are Python and Go, if it matters.

10-ish years ago I had 5-ish years of python experience and used the official Java docs/tutorial thingy and picked it up pretty quickly.

I don't do much Java anymore, but I still to this day hear the official tutorial recommended.

Casual Encountess
Dec 14, 2005

"You can see how they go from being so sweet to tearing your face off,
just like that,
and it's amazing to have that range."


Thunderdome Exclusive

downout posted:

Do you have any programming experience?

yeah. intermediate but i haven’t done a lot of web stuff. my bulk of programming expertise was having to learn fortran and cobol for legacy hardware and i basically have refused to program since.

Shy
Mar 20, 2010

Am I missing something or do JetBrains IDEs outside of DataGrip not offer SQL code formatting?

Adbot
ADBOT LOVES YOU

downout
Jul 6, 2009

Casual Encountess posted:

yeah. intermediate but i haven’t done a lot of web stuff. my bulk of programming expertise was having to learn fortran and cobol for legacy hardware and i basically have refused to program since.

There are a couple things you could use with .net to easily manipulate excel and scrape public web pages. Other than building something custom, i'm not sure how else to automate such a process.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply